Skip to content

Commit e02fba6

Browse files
Alitindrawan24Kovah
authored andcommitted
feat(tags): add filter functionality to tag listing page on guest
1 parent 6dd6cbd commit e02fba6

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

app/Http/Controllers/Guest/TagController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ public function index(Request $request): View
2828

2929
$tags = Tag::publicOnly()
3030
->withCount(['links' => fn($query) => $query->publicOnly()])
31-
->orderBy($this->orderBy, $this->orderDir)
32-
->paginate(getPaginationLimit());
31+
->orderBy($this->orderBy, $this->orderDir);
32+
33+
if ($request->input('filter')) {
34+
$tags = $tags->where('name', 'like', '%' . $request->input('filter') . '%');
35+
}
36+
37+
$tags = $tags->paginate(getPaginationLimit());
3338

3439
return view('guest.tags.index', [
3540
'pageTitle' => trans('tag.tags'),

resources/views/guest/tags/index.blade.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,28 @@
1010
<h3 class="mb-0 me-3">
1111
@lang('tag.tags')
1212
</h3>
13-
<a href="{{ route('guest.tags.feed') }}" class="ms-auto btn btn-sm btn-outline-secondary">
14-
<x-icon.feed/>
15-
<span class="visually-hidden">@lang('linkace.feed')</span>
16-
</a>
13+
<div class="mb-0 ms-auto">
14+
<div class="d-flex flex-column flex-sm-row gap-3">
15+
<form action="{{ route('guest.tags.index') }}" method="GET">
16+
<label for="filter" class="visually-hidden">@lang('tag.filter_tags')</label>
17+
<div class="input-group input-group-sm mb-1 mb-sm-0 me-sm-2">
18+
<input type="text" name="filter" id="filter" minlength="1"
19+
class="form-control" placeholder="@lang('tag.filter_tags')"
20+
value="{{ request()->input('filter') }}"/>
21+
<a href="{{ route('guest.tags.index') }}" class="btn btn-sm btn-outline-primary">
22+
<x-icon.ban/>
23+
</a>
24+
<button class="btn btn-primary" type="submit" title="@lang('list.filter_lists')">
25+
<x-icon.search/>
26+
</button>
27+
</div>
28+
</form>
29+
<a href="{{ route('guest.tags.feed') }}" class="ms-auto btn btn-sm btn-outline-secondary">
30+
<x-icon.feed/>
31+
<span class="visually-hidden">@lang('linkace.feed')</span>
32+
</a>
33+
</div>
34+
</div>
1735
</header>
1836

1937
<div class="tags-listing card my-3 mb-3">

0 commit comments

Comments
 (0)