Merge pull request '更新首页接口' (#13) from zhangwei into dev

Reviewed-on: #13
This commit is contained in:
weiz 2023-11-25 10:39:46 +08:00
commit cdeace5825
1 changed files with 9 additions and 9 deletions

View File

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