Skip to content

Commit eb17d8c

Browse files
committed
add: search within playlists by torrent name
1 parent ad1b66e commit eb17d8c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

app/Http/Controllers/PlaylistController.php

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public function show(Request $request, Playlist $playlist): \Illuminate\Contract
113113
WHEN category_id IN (SELECT id from categories where no_meta = TRUE) THEN 'no'
114114
END as meta
115115
SQL)
116+
->when($request->has('search'), fn ($query) => $query->where('name', 'LIKE', '%'.str_replace(' ', '%', $request->search).'%'))
116117
->with(['category', 'resolution', 'type', 'user.group'])
117118
->orderBy('name')
118119
->paginate(26);
@@ -129,6 +130,7 @@ public function show(Request $request, Playlist $playlist): \Illuminate\Contract
129130
},
130131
'latestPlaylistTorrent' => $playlist->torrents()->orderByPivot('created_at', 'desc')->first(),
131132
'torrents' => $torrents,
133+
'search' => $request->search,
132134
]);
133135
}
134136

resources/views/playlist/show.blade.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,28 @@ class="playlist__author-avatar"
200200
</div>
201201
</section>
202202
<section class="panelV2">
203-
<h2 class="panel__heading">{{ __('torrent.torrents') }}</h2>
203+
<header class="panel__header">
204+
<h2 class="panel__heading">{{ __('torrent.torrents') }}</h2>
205+
<div class="panel__actions">
206+
<form
207+
class="panel__action"
208+
action="{{ route('playlists.show', ['playlist' => $playlist]) }}"
209+
>
210+
<div class="form__group">
211+
<input
212+
class="form__text"
213+
type="text"
214+
name="search"
215+
placeholder=" "
216+
value="{{ $search }}"
217+
/>
218+
<label class="form__label form__label--floating">
219+
{{ __('common.search') }}
220+
</label>
221+
</div>
222+
</form>
223+
</div>
224+
</header>
204225
<div class="panel__body playlist__torrents">
205226
@foreach ($torrents as $torrent)
206227
<div class="playlist__torrent-container">

0 commit comments

Comments
 (0)