From a0954bc936e16994f98bbd5128baff6519e511bd Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sun, 14 Aug 2022 17:56:21 +0100 Subject: [PATCH] Add the page for tagged bookmarks --- app/Http/Controllers/BookmarksController.php | 15 +++++++ resources/views/bookmarks/tagged.blade.php | 47 ++++++++++++++++++++ routes/web.php | 1 + 3 files changed, 63 insertions(+) create mode 100644 resources/views/bookmarks/tagged.blade.php diff --git a/app/Http/Controllers/BookmarksController.php b/app/Http/Controllers/BookmarksController.php index 3779a476..b72047de 100644 --- a/app/Http/Controllers/BookmarksController.php +++ b/app/Http/Controllers/BookmarksController.php @@ -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')); + } } diff --git a/resources/views/bookmarks/tagged.blade.php b/resources/views/bookmarks/tagged.blade.php new file mode 100644 index 00000000..4e7b59ea --- /dev/null +++ b/resources/views/bookmarks/tagged.blade.php @@ -0,0 +1,47 @@ +@extends('master') + +@section('title')Bookmarks « @stop + +@section('content') +
+

Bookmarks tagged with {{ $tag }}

+ @foreach($bookmarks as $bookmark) +
+ + @isset($bookmark->content) +

{{ $bookmark->content }}

+ @endisset + + @isset($bookmark->screenshot) + + @endisset + + @isset($bookmark->archive) +

Internet Archive backup

+ @endisset + + @if($bookmark->tags_count > 0) +
    + @foreach($bookmark->tags as $tag) +
  • + {{ $tag->tag }} +
  • + @endforeach +
+ @endif +
+ @endforeach +
+ + {{ $bookmarks->links() }} +@stop diff --git a/routes/web.php b/routes/web.php index 574bba01..7d812aac 100644 --- a/routes/web.php +++ b/routes/web.php @@ -158,6 +158,7 @@ Route::group(['domain' => config('url.longurl')], function () { Route::group(['prefix' => 'bookmarks'], function () { Route::get('/', [BookmarksController::class, 'index']); Route::get('/{bookmark}', [BookmarksController::class, 'show']); + Route::get('/tagged/{tag}', [BookmarksController::class, 'tagged']); }); // Token Endpoint