1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-19 14:32:19 +02:00

Added ability to filter (search) for tags

on tags index page.
This commit is contained in:
Gavin Rehkemper 2021-09-12 22:28:39 +00:00
parent 6589c92b49
commit 2305da649e
6 changed files with 41 additions and 6 deletions

View File

@ -27,13 +27,20 @@ class TagController extends Controller
->orderBy(
$request->input('orderBy', 'name'),
$request->input('orderDir', 'ASC')
)->paginate(getPaginationLimit());
);
if($request->input('filter')) {
$tags = $tags->where('name', 'like', '%' . $request->input('filter') . '%');
}
$tags = $tags->paginate(getPaginationLimit());
return view('models.tags.index', [
'tags' => $tags,
'route' => $request->getBaseUrl(),
'orderBy' => $request->input('orderBy', 'name'),
'orderDir' => $request->input('orderDir', 'ASC'),
'filter' => $request->input('filter')
]);
}

View File

@ -11,6 +11,8 @@ return [
'update' => 'Tag aktualisieren',
'delete' => 'Tag löschen',
'filter_tags' => '',
'private' => 'Privater Tag',
'name' => 'Name das Tags',

View File

@ -11,6 +11,8 @@ return [
'update' => 'Update Tag',
'delete' => 'Delete Tag',
'filter_tags' => 'Filter Tags...',
'private' => 'Private Tag',
'name' => 'Tag Name',

View File

@ -11,6 +11,8 @@ return [
'update' => 'Mettre à jour Étiquette',
'delete' => 'Supprimer Étiquette',
'filter_tags' => '',
'private' => 'Étiquette Privée',
'name' => 'Nom Étiquette',

View File

@ -11,6 +11,8 @@ return [
'update' => '更新标签',
'delete' => '删除标签',
'filter_tags' => '',
'private' => '私人标签',
'name' => '标签名',

View File

@ -6,10 +6,30 @@
<h3 class="mb-0">
@lang('tag.tags')
</h3>
<a href="{{ route('tags.create') }}" class="btn btn-sm btn-primary ml-auto" aria-label="@lang('link.add')">
<x-icon.plus class="mr-2"/>
@lang('linkace.add')
</a>
<div class="form-group ml-auto">
<form action="{{ route('tags.index') }}" method="GET">
<div class="input-group input-group-sm">
<label for="filter" class="sr-only">@lang('tag.filter_tags')</label>
<input type="text" name="filter" id="filter" autofocus minlength="1"
class="form-control mr-2" placeholder="@lang('tag.filter_tags')"
value="{{ request()->input('filter') }}" />
<a href="{{ route('tags.index') }}" class="btn btn-sm bg-transparent" style="margin-left: -40px; z-index: 100;">
<x-icon.ban />
</a>
<div class="input-group-append mr-2">
<button class="btn btn-primary" type="submit">
<x-icon.search />
</button>
</div>
<a href="{{ route('tags.create') }}" class="btn btn-sm btn-primary" aria-label="@lang('link.add')">
<x-icon.plus class="mr-2"/>
@lang('linkace.add')
</a>
</div>
</form>
</div>
</header>
<div class="card my-3">
@ -31,7 +51,7 @@
</div>
@if($tags->isNotEmpty())
{!! $tags->onEachSide(1)->appends(['orderBy' => $orderBy, 'orderDir' => $orderDir])->links() !!}
{!! $tags->onEachSide(1)->appends(['orderBy' => $orderBy, 'orderDir' => $orderDir, 'filter' => $filter])->links() !!}
@endif
@endsection