From 3870b38c56eba735c261b8e12e348dd1427e64cf Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Mon, 16 Jun 2025 15:58:34 +0800 Subject: [PATCH] 1 --- app/controller/LocationController.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/controller/LocationController.php b/app/controller/LocationController.php index ebb220d..93869ee 100644 --- a/app/controller/LocationController.php +++ b/app/controller/LocationController.php @@ -58,18 +58,23 @@ class LocationController $locations_id = $vehicles->groupBy('locations_id')->get(); $locations_id = $locations_id->pluck('locations_id')->toArray(); - $locations = Location::with('vehicles') - ->with('fboVehicles') - ->where(['type' => 'production']) + $locations = Location:: +// with('vehicles') +// ->with('fboVehicles') + where(['type' => 'production']) ->whereIn('id',$locations_id) - ->get() - ->map(function ($location) { - $location->vehicle_count = $location->vehicles->count(); - $location->fbo_vehicle_count = $location->fboVehicles->count(); - $location->count = ($location->vehicle_count > 0) ? $location->vehicle_count : $location->fbo_vehicle_count; - return $location; - }); + ->get(); +// ->map(function ($location) { +// $location->vehicle_count = $location->vehicles->count(); +// $location->fbo_vehicle_count = $location->fboVehicles->count(); +// $location->count = ($location->vehicle_count > 0) ? $location->vehicle_count : $location->fbo_vehicle_count; +// return $location; +// }); foreach ($locations as &$location) { + $location->vehicle_count = Vehicle::where(['locations_id'=>$location->id])->count(); + $location->fbo_vehicle_count = Vehicle::where(['fbo_locations_id'=>$location->id])->count(); + $location->count = ($location->vehicle_count > 0) ? $location->vehicle_count : $location->fbo_vehicle_count; + $location->status = $request->post('status', ''); unset($location->vehicles); unset($location->fboVehicles);