add: request #3745

- closes #3745
This commit is contained in:
HDVinnie
2024-04-17 19:29:49 -04:00
parent fc399fd61a
commit 41db02b0ac
2 changed files with 91 additions and 11 deletions
+8 -8
View File
@@ -62,6 +62,12 @@ class TorrentRequestSearch extends Component
#[Url(history: true)]
public array $genres = [];
/**
* @var string[]
*/
#[Url(history: true)]
public array $primaryLanguages = [];
#[Url(history: true)]
public ?int $tmdbId = null;
@@ -107,19 +113,11 @@ class TorrentRequestSearch extends Component
#[Url(history: true)]
public string $sortDirection = 'desc';
#[Url(history: true)]
public bool $showFilters = false;
final public function updating(string $field, mixed &$value): void
{
$this->castLivewireProperties($field, $value);
}
final public function toggleShowFilters(): void
{
$this->showFilters = !$this->showFilters;
}
#[Computed]
final public function torrentRequestStat(): ?object
{
@@ -165,6 +163,8 @@ class TorrentRequestSearch extends Component
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
->when($this->tvdbId !== null, fn ($query) => $query->ofTvdb((int) $this->tvdbId))
->when($this->malId !== null, fn ($query) => $query->ofMal((int) $this->malId))
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
->when($this->primaryLanguages !== [], fn ($query) => $query->ofPrimaryLanguage($this->primaryLanguages))
->when($this->unfilled || $this->claimed || $this->pending || $this->filled, function ($query): void {
$query->where(function ($query): void {
$query->where(function ($query): void {
@@ -205,7 +205,14 @@
<fieldset class="form__fieldset">
<legend class="form__legend">{{ __('torrent.category') }}</legend>
<div class="form__fieldset-checkbox-container">
@foreach (App\Models\Category::select(['id', 'name', 'position'])->orderBy('position')->get() as $category)
@php
$categories = cache()->remember(
'categories',
3_600,
fn () => App\Models\Category::orderBy('position')->get()
)
@endphp
@foreach ($categories as $category)
<p class="form__group">
<label class="form__label">
<input
@@ -225,7 +232,14 @@
<fieldset class="form__fieldset">
<legend class="form__legend">{{ __('common.type') }}</legend>
<div class="form__fieldset-checkbox-container">
@foreach (App\Models\Type::select(['id', 'name', 'position'])->orderBy('position')->get() as $type)
@php
$types = cache()->remember(
'types',
3_600,
fn () => App\Models\Type::orderBy('position')->get()
)
@endphp
@foreach ($types as $type)
<p class="form__group">
<label class="form__label">
<input
@@ -245,7 +259,14 @@
<fieldset class="form__fieldset">
<legend class="form__legend">{{ __('common.resolution') }}</legend>
<div class="form__fieldset-checkbox-container">
@foreach (App\Models\Resolution::select(['id', 'name', 'position'])->orderBy('position')->get() as $resolution)
@php
$resolutions = cache()->remember(
'resolutions',
3_600,
fn () => App\Models\Resolution::orderBy('position')->get()
)
@endphp
@foreach ($resolutions as $resolution)
<p class="form__group">
<label class="form__label">
<input
@@ -261,6 +282,65 @@
</div>
</fieldset>
</div>
<div class="form__group">
<fieldset class="form__fieldset">
<legend class="form__legend">{{ __('torrent.genre') }}</legend>
<div class="form__fieldset-checkbox-container">
@php
$genres = cache()->remember(
'genres',
3_600,
fn () => App\Models\Genre::orderBy('name')->get()
)
@endphp
@foreach ($genres as $genre)
<p class="form__group">
<label class="form__label">
<input
class="form__checkbox"
type="checkbox"
value="{{ $genre->id }}"
wire:model.live="genres"
/>
{{ $genre->name }}
</label>
</p>
@endforeach
</div>
</fieldset>
</div>
<div class="form__group">
<fieldset class="form__fieldset">
<legend class="form__legend">Primary Language</legend>
<div class="form__fieldset-checkbox-container">
@php
$primaryLanguages = cache()->remember(
'torrent-search:languages',
3600,
fn () => App\Models\Movie::select('original_language')
->distinct()
->orderBy('original_language')
->pluck('original_language')
)
@endphp
@foreach ($primaryLanguages as $primaryLanguage)
<p class="form__group">
<label class="form__label">
<input
class="form__checkbox"
type="checkbox"
value="{{ $primaryLanguage }}"
wire:model.live="primaryLanguages"
/>
{{ $primaryLanguage }}
</label>
</p>
@endforeach
</div>
</fieldset>
</div>
<div class="form__group">
<fieldset class="form__fieldset">
<legend class="form__legend">{{ __('common.status') }}</legend>