1
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user