From e02fba6aa754ac56847e0f4d5234030f6cb80fb3 Mon Sep 17 00:00:00 2001 From: Alit Indrawan Date: Tue, 7 Oct 2025 20:18:58 +0800 Subject: [PATCH 1/2] feat(tags): add filter functionality to tag listing page on guest --- app/Http/Controllers/Guest/TagController.php | 9 +++++-- resources/views/guest/tags/index.blade.php | 26 +++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Guest/TagController.php b/app/Http/Controllers/Guest/TagController.php index 89fb929f9..f27fa07f0 100644 --- a/app/Http/Controllers/Guest/TagController.php +++ b/app/Http/Controllers/Guest/TagController.php @@ -28,8 +28,13 @@ public function index(Request $request): View $tags = Tag::publicOnly() ->withCount(['links' => fn($query) => $query->publicOnly()]) - ->orderBy($this->orderBy, $this->orderDir) - ->paginate(getPaginationLimit()); + ->orderBy($this->orderBy, $this->orderDir); + + if ($request->input('filter')) { + $tags = $tags->where('name', 'like', '%' . $request->input('filter') . '%'); + } + + $tags = $tags->paginate(getPaginationLimit()); return view('guest.tags.index', [ 'pageTitle' => trans('tag.tags'), diff --git a/resources/views/guest/tags/index.blade.php b/resources/views/guest/tags/index.blade.php index 8b97ea494..ace9c8cee 100644 --- a/resources/views/guest/tags/index.blade.php +++ b/resources/views/guest/tags/index.blade.php @@ -10,10 +10,28 @@

@lang('tag.tags')

- - - @lang('linkace.feed') - +
+
+
+ +
+ + + + + +
+
+ + + @lang('linkace.feed') + +
+
From 6438170b3fbc8b415a7f3d20852a83b385c85ac9 Mon Sep 17 00:00:00 2001 From: Alit Indrawan Date: Tue, 7 Oct 2025 20:19:08 +0800 Subject: [PATCH 2/2] test(guest/tag): add tag search test cases --- tests/Controller/Guest/TagControllerTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Controller/Guest/TagControllerTest.php b/tests/Controller/Guest/TagControllerTest.php index 7b1a3b099..73bfc0c68 100644 --- a/tests/Controller/Guest/TagControllerTest.php +++ b/tests/Controller/Guest/TagControllerTest.php @@ -67,4 +67,22 @@ public function test_invalid_tag_detail_response(): void $this->get('guest/tags/1')->assertNotFound(); $this->get('guest/tags/myTag')->assertNotFound(); } + + public function test_tag_search(): void + { + User::factory()->create(); + Tag::factory()->create([ + 'name' => 'testTag1', + 'visibility' => 1, + ]); + Tag::factory()->create([ + 'name' => 'testTag2', + 'visibility' => 1, + ]); + $this->get('guest/tags?filter=testTag1')->assertSee('testTag1') + ->assertDontSee('testTag2'); + + $this->get('guest/tags?filter=testTag2')->assertSee('testTag2') + ->assertDontSee('testTag1'); + } }