Optimize query with eager loading
This commit is contained in:
@@ -56,7 +56,7 @@ class AircraftController extends Controller
|
||||
$w['subfleet_id'] = $request->input('subfleet');
|
||||
}
|
||||
|
||||
$aircraft = $this->aircraftRepo->whereOrder($w, 'registration', 'asc');
|
||||
$aircraft = $this->aircraftRepo->with(['subfleet'])->whereOrder($w, 'registration', 'asc');
|
||||
$aircraft = $aircraft->all();
|
||||
|
||||
return view('admin.aircraft.index', [
|
||||
|
||||
@@ -133,6 +133,7 @@ class FlightController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$flights = $this->flightRepo
|
||||
->with(['dpt_airport', 'arr_airport', 'alt_airport', 'airline'])
|
||||
->searchCriteria($request, false)
|
||||
->orderBy('flight_number', 'asc')
|
||||
->paginate();
|
||||
|
||||
@@ -199,6 +199,7 @@ class PirepController extends Controller
|
||||
$this->pirepRepo->pushCriteria($criterea);
|
||||
|
||||
$pireps = $this->pirepRepo
|
||||
->with(['airline', 'aircraft', 'dpt_airport', 'arr_airport'])
|
||||
->whereNotInOrder('state', [
|
||||
PirepState::CANCELLED,
|
||||
PirepState::DRAFT,
|
||||
|
||||
@@ -119,7 +119,7 @@ class SubfleetController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->subfleetRepo->pushCriteria(new RequestCriteria($request));
|
||||
$this->subfleetRepo->with(['airline'])->pushCriteria(new RequestCriteria($request));
|
||||
$subfleets = $this->subfleetRepo->all();
|
||||
|
||||
return view('admin.subfleets.index', [
|
||||
|
||||
Reference in New Issue
Block a user