'视频监控', self::TYPE_SOIL => '土壤监测', // self::TYPE_WATER_QUALITY => '水质监测', self::TYPE_METEOROLOGICAL => '气象监测', self::TYPE_AIR => '通风控制', self::TYPE_ATOMIZING => '喷雾控制', self::TYPE_INSECT => '虫情监测', ]; } public static function fieldMap($type) { $arr = []; switch ($type) { case self::TYPE_SOIL: $arr = [ 'conductivity'=>'导电率', 'humidity'=>'湿度', 'temperature'=>'温度', 'n'=>'氮', 'p'=>'磷', 'k'=>'钾' ]; break; case self::TYPE_WATER_QUALITY: $arr = [ ]; break; case self::TYPE_METEOROLOGICAL: $arr = [ 'box_temperature' => '温度', 'box_humidity' => '湿度', 'box_illumination' => '光照强度', 'moment_rainfall' => '降雨量', 'wind_speed' => '风速', 'wind_direction' => '风向', 'box_noise' => '噪音', 'pm10' => 'PM10', 'pm25' => 'PM25', 'box_co2' => 'CO2' ]; break; } return $arr; } public static function fieldUnitMap($type) { $arr = []; switch ($type) { case self::TYPE_SOIL: $arr = [ 'conductivity'=>'us/cm', 'humidity'=>'%RH', 'temperature'=>'℃', 'n'=>'n', 'p'=>'p', 'k'=>'k' ]; break; case self::TYPE_WATER_QUALITY: $arr = [ ]; break; case self::TYPE_METEOROLOGICAL: $arr = [ 'box_temperature' => '℃', 'box_humidity' => '%RH', 'box_illumination' => 'Lux', 'moment_rainfall' => 'mm', 'wind_speed' => 'm/s', 'wind_direction' => '', 'box_noise' => 'db', 'pm10' => 'ug/m3', 'pm25' => 'ug/m3', 'box_co2' => 'ppm' ]; break; } return $arr; } protected function serializeDate(\DateTimeInterface $date){ return $date->format('Y-m-d H:i:s'); } protected function tags():Attribute { return Attribute::make( get: fn($value) => $this->group_tags ? explode(',', $this->group_tags) : [], ); } public function devices(){ return $this->belongsToMany(Device::class, MonitorDevice::class, 'monitor_id', 'device_id')->withPivot('fields'); } }