mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 19:01:29 +00:00
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class AdminReleaseListRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$search = $this->input('search');
|
|
|
|
$this->merge([
|
|
'search' => is_string($search) ? trim($search) : $search,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, list<string>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'search' => ['nullable', 'string', 'max:255'],
|
|
'category_id' => ['nullable', 'integer'],
|
|
'page' => ['nullable', 'integer', 'min:1'],
|
|
];
|
|
}
|
|
|
|
public function searchTerm(): ?string
|
|
{
|
|
$search = $this->validated('search');
|
|
|
|
return is_string($search) && $search !== '' ? $search : null;
|
|
}
|
|
|
|
public function categoryId(): ?int
|
|
{
|
|
$categoryId = $this->validated('category_id');
|
|
|
|
if ($categoryId === null || (int) $categoryId === -1) {
|
|
return null;
|
|
}
|
|
|
|
return (int) $categoryId;
|
|
}
|
|
}
|