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);