Add the page for tagged bookmarks

This commit is contained in:
Jonny Barnes 2022-08-14 17:56:21 +01:00
parent e23ba75021
commit a0954bc936
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
3 changed files with 63 additions and 0 deletions

View file

@ -33,4 +33,19 @@ class BookmarksController extends Controller
return view('bookmarks.show', compact('bookmark'));
}
/**
* Show bookmakrs tagged with a specific tag.
*
* @param string $tag
* @return View
*/
public function tagged(string $tag): View
{
$bookmarks = Bookmark::whereHas('tags', function ($query) use ($tag) {
$query->where('tag', $tag);
})->latest()->with('tags')->withCount('tags')->paginate(10);
return view('bookmarks.tagged', compact('bookmarks', 'tag'));
}
}