Fix the number of queries being made

This commit is contained in:
Jonny Barnes 2017-10-11 18:04:05 +01:00
parent d41d085853
commit f16034d963
3 changed files with 5 additions and 3 deletions

View file

@ -8,13 +8,15 @@ class BookmarksController extends Controller
{
public function index()
{
$bookmarks = Bookmark::with('tags')->latest()->paginate(10);
$bookmarks = Bookmark::latest()->with('tags')->withCount('tags')->paginate(10);
return view('bookmarks.index', compact('bookmarks'));
}
public function show(Bookmark $bookmark)
{
$bookmark->loadMissing('tags');
return view('bookmarks.show', compact('bookmark'));
}
}