Fix the number of queries being made
This commit is contained in:
parent
d41d085853
commit
f16034d963
3 changed files with 5 additions and 3 deletions
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ Bookmarks «
|
|||
@isset($bookmark->content)
|
||||
<p>{{ $bookmark->content }}</p>
|
||||
@endisset
|
||||
@if(count($bookmark->tags()->get()) > 0)
|
||||
@if($bookmark->tags_count > 0)
|
||||
<ul>
|
||||
@foreach($bookmark->tags as $tag)
|
||||
<li><a href="/bookmarks/tagged/{{ $tag->tag }}">{{ $tag->tag }}</a></li>
|
||||
|
|
|
@ -18,7 +18,7 @@ Bookmark «
|
|||
@isset($bookmark->content)
|
||||
<p>{{ $bookmark->content }}</p>
|
||||
@endisset
|
||||
@if(count($bookmark->tags()->get()) > 0)
|
||||
@if(count($bookmark->tags) > 0)
|
||||
<ul>
|
||||
@foreach($bookmark->tags as $tag)
|
||||
<li><a href="/bookmarks/tagged/{{ $tag->tag }}">{{ $tag->tag }}</a></li>
|
||||
|
|
Loading…
Add table
Reference in a new issue