This commit is contained in:
chenbo 2024-01-31 16:29:50 +08:00
parent 676bb5627e
commit ae32963785
1 changed files with 9 additions and 6 deletions

View File

@ -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;
}