Optimize query with eager loading
This commit is contained in:
@@ -56,7 +56,7 @@ class AircraftController extends Controller
|
|||||||
$w['subfleet_id'] = $request->input('subfleet');
|
$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();
|
$aircraft = $aircraft->all();
|
||||||
|
|
||||||
return view('admin.aircraft.index', [
|
return view('admin.aircraft.index', [
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ class FlightController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$flights = $this->flightRepo
|
$flights = $this->flightRepo
|
||||||
|
->with(['dpt_airport', 'arr_airport', 'alt_airport', 'airline'])
|
||||||
->searchCriteria($request, false)
|
->searchCriteria($request, false)
|
||||||
->orderBy('flight_number', 'asc')
|
->orderBy('flight_number', 'asc')
|
||||||
->paginate();
|
->paginate();
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class PirepController extends Controller
|
|||||||
$this->pirepRepo->pushCriteria($criterea);
|
$this->pirepRepo->pushCriteria($criterea);
|
||||||
|
|
||||||
$pireps = $this->pirepRepo
|
$pireps = $this->pirepRepo
|
||||||
|
->with(['airline', 'aircraft', 'dpt_airport', 'arr_airport'])
|
||||||
->whereNotInOrder('state', [
|
->whereNotInOrder('state', [
|
||||||
PirepState::CANCELLED,
|
PirepState::CANCELLED,
|
||||||
PirepState::DRAFT,
|
PirepState::DRAFT,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class SubfleetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->subfleetRepo->pushCriteria(new RequestCriteria($request));
|
$this->subfleetRepo->with(['airline'])->pushCriteria(new RequestCriteria($request));
|
||||||
$subfleets = $this->subfleetRepo->all();
|
$subfleets = $this->subfleetRepo->all();
|
||||||
|
|
||||||
return view('admin.subfleets.index', [
|
return view('admin.subfleets.index', [
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ class PirepController extends Controller
|
|||||||
$where = [['user_id', $user->id]];
|
$where = [['user_id', $user->id]];
|
||||||
$where[] = ['state', '<>', PirepState::CANCELLED];
|
$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();
|
$pireps = $this->pirepRepo->orderBy('created_at', 'desc')->paginate();
|
||||||
|
|
||||||
return view('pireps.index', [
|
return view('pireps.index', [
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class LatestPilots extends Widget
|
|||||||
|
|
||||||
return view('widgets.latest_pilots', [
|
return view('widgets.latest_pilots', [
|
||||||
'config' => $this->config,
|
'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);
|
$pirepRepo = app(PirepRepository::class);
|
||||||
|
|
||||||
$pireps = $pirepRepo
|
$pireps = $pirepRepo
|
||||||
|
->with(['airline', 'aircraft'])
|
||||||
->whereNotInOrder('state', [
|
->whereNotInOrder('state', [
|
||||||
PirepState::CANCELLED,
|
PirepState::CANCELLED,
|
||||||
PirepState::DRAFT,
|
PirepState::DRAFT,
|
||||||
|
|||||||
Reference in New Issue
Block a user