(Update) Optimize Queries

- eager loading
This commit is contained in:
HDVinnie
2018-10-17 14:15:18 -04:00
parent dfcd5338c2
commit b777ef03e2
6 changed files with 13 additions and 12 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ class RequestController extends Controller
$claimed_bounty = TorrentRequest::whereNotNull('filled_by')->sum('bounty');
$unclaimed_bounty = TorrentRequest::whereNull('filled_by')->sum('bounty');
$torrentRequests = TorrentRequest::with('user','category')->paginate(25);
$torrentRequests = TorrentRequest::with(['user', 'category'])->paginate(25);
$repository = $this->repository;
return view('requests.requests', [
@@ -107,7 +107,7 @@ class RequestController extends Controller
$search .= '%' . $term . '%';
}
$torrentRequest = $torrentRequest->with('user','category');
$torrentRequest = $torrentRequest->with(['user', 'category']);
if ($request->has('search') && $request->input('search') != null) {
$torrentRequest->where('name', 'like', $search);