新增监控点位通过实验田ID查询
parent
45d9aa724d
commit
461761d4ae
|
|
@ -7,6 +7,12 @@ use App\Models\Device;
|
||||||
|
|
||||||
class MonitorModeFilter extends ModelFilter
|
class MonitorModeFilter extends ModelFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function region($region){
|
||||||
|
return $this->whereHas('region', function($q)use($region){
|
||||||
|
return $q->where('regions.id', $region);
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class MonitorModeResource extends JsonResource
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
'type' => $this->type,
|
||||||
'name' => $this->name
|
'name' => $this->name
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,10 @@ class MonitorMode extends Model
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function region(){
|
||||||
|
return $this->belongsToMany(Region::class, RegionMonitor::class, 'monitor_id', 'region_id')->withTimestamps();
|
||||||
|
}
|
||||||
|
|
||||||
public function devices(){
|
public function devices(){
|
||||||
return $this->belongsToMany(Device::class, MonitorDevice::class, 'monitor_id', 'device_id')->withPivot('fields');
|
return $this->belongsToMany(Device::class, MonitorDevice::class, 'monitor_id', 'device_id')->withPivot('fields');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue