更新首页接口 #13

Merged
weiz merged 1 commits from zhangwei into dev 2023-11-25 10:39:46 +08:00
1 changed files with 9 additions and 9 deletions
Showing only changes of commit 129a96b082 - Show all commits

View File

@ -46,24 +46,24 @@ class IndexController extends BaseApiController
//获取监测数据 //获取监测数据
$landDeviceForSoil = LandDevice::where('land_id',$land['id'])->where('device_type',1)->findOrEmpty(); $landDeviceForSoil = LandDevice::where('land_id',$land['id'])->where('device_type',1)->findOrEmpty();
if($landDeviceForSoil->isEmpty()){ if($landDeviceForSoil->isEmpty()){
$data['soil_device'] = 0; $land['soil_device'] = 0;
}else{ }else{
$data['soil_device'] = 1; $land['soil_device'] = 1;
$data['soil_monitor_data'] = SoilMonitor::where('device_id',$landDeviceForSoil['device_id'])->order('id desc')->findOrEmpty(); $land['soil_monitor_data'] = SoilMonitor::where('device_id',$landDeviceForSoil['device_id'])->order('id desc')->findOrEmpty();
} }
$landDeviceForAir = LandDevice::where('land_id',$land['id'])->where('device_type',2)->findOrEmpty(); $landDeviceForAir = LandDevice::where('land_id',$land['id'])->where('device_type',2)->findOrEmpty();
if($landDeviceForAir->isEmpty()){ if($landDeviceForAir->isEmpty()){
$data['air_device'] = 0; $land['air_device'] = 0;
}else{ }else{
$data['air_device'] = 1; $land['air_device'] = 1;
$data['air_monitor_data'] = AirMonitor::where('device_id',$landDeviceForAir['device_id'])->order('id desc')->findOrEmpty(); $land['air_monitor_data'] = AirMonitor::where('device_id',$landDeviceForAir['device_id'])->order('id desc')->findOrEmpty();
} }
$landDeviceForVideo = LandDevice::where('land_id',$land['id'])->where('device_type',3)->findOrEmpty(); $landDeviceForVideo = LandDevice::where('land_id',$land['id'])->where('device_type',3)->findOrEmpty();
if($landDeviceForVideo->isEmpty()){ if($landDeviceForVideo->isEmpty()){
$data['video_device'] = 0; $land['video_device'] = 0;
}else{ }else{
$data['video_device'] = 1; $land['video_device'] = 1;
$data['video_monitor_data'] = ''; $land['video_monitor_data'] = '';
} }
return $this->success('请求成功',$land->toArray()); return $this->success('请求成功',$land->toArray());
} }