diff --git a/app/adminapi/logic/fence_house/FenceHouseLogic.php b/app/adminapi/logic/fence_house/FenceHouseLogic.php index 40060b7..9c85727 100644 --- a/app/adminapi/logic/fence_house/FenceHouseLogic.php +++ b/app/adminapi/logic/fence_house/FenceHouseLogic.php @@ -124,12 +124,15 @@ class FenceHouseLogic extends BaseLogic public static function detail($params): array { $data = FenceHouse::findOrEmpty($params['id'])->toArray(); - $product = Product::where('fence_house_id', $params['id'])->findOrEmpty()->toArray(); - $deviceIds = ProductDevice::where('product_id', $product['id'])->column('device_id'); - $device = Device::whereIn('id', $deviceIds)->where('type', 2)->findOrEmpty(); - $data['video_url'] = $device['video_url']; - $data['device_id'] = $device['id']; - + $product = Product::where('fence_house_id', $data['id'])->findOrEmpty()->toArray(); + $data['video_url'] = ''; + $data['device_id'] = 0; + if (!empty($product)) { + $deviceIds = ProductDevice::where('product_id', $product['id'])->column('device_id'); + $device = Device::whereIn('id', $deviceIds)->where('type', 2)->findOrEmpty(); + $data['video_url'] = $device['video_url']; + $data['device_id'] = $device['id']; + } return $data; }