Optimize query with eager loading

This commit is contained in:
Kevin
2018-09-04 20:02:16 +08:00
parent c95fe3c971
commit f7ae027156
7 changed files with 8 additions and 4 deletions

View File

@@ -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']),
]);
}
}

View File

@@ -23,6 +23,7 @@ class LatestPireps extends Widget
$pirepRepo = app(PirepRepository::class);
$pireps = $pirepRepo
->with(['airline', 'aircraft'])
->whereNotInOrder('state', [
PirepState::CANCELLED,
PirepState::DRAFT,