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', [
|
||||
|
||||
@@ -180,7 +180,8 @@ class PirepController extends Controller
|
||||
$where = [['user_id', $user->id]];
|
||||
$where[] = ['state', '<>', PirepState::CANCELLED];
|
||||
|
||||
$this->pirepRepo->pushCriteria(new WhereCriteria($request, $where));
|
||||
$this->pirepRepo->with(['airline', 'aircraft', 'dpt_airport', 'arr_airport'])
|
||||
->pushCriteria(new WhereCriteria($request, $where));
|
||||
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();
|
||||
|
||||
return view('pireps.index', [
|
||||
|
||||
@@ -23,7 +23,7 @@ class LatestPilots extends Widget
|
||||
|
||||
return view('widgets.latest_pilots', [
|
||||
'config' => $this->config,
|
||||
'users' => $userRepo->recent($this->config['count']),
|
||||
'users' => $userRepo->with(['airline'])->recent($this->config['count']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class LatestPireps extends Widget
|
||||
$pirepRepo = app(PirepRepository::class);
|
||||
|
||||
$pireps = $pirepRepo
|
||||
->with(['airline', 'aircraft'])
|
||||
->whereNotInOrder('state', [
|
||||
PirepState::CANCELLED,
|
||||
PirepState::DRAFT,
|
||||
|
||||
Reference in New Issue
Block a user