43 lines
957 B
PHP
43 lines
957 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Back\Recipes;
|
|
|
|
use App\Services\AdminAuthService;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class IndexRecipeRequest extends FormRequest
|
|
{
|
|
public function __construct(
|
|
private readonly AdminAuthService $authService
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->authService->check();
|
|
}
|
|
|
|
public function getSearchValue(): ?string
|
|
{
|
|
return $this->has('search') ?
|
|
$this->string('search')->value() : null;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'search' => ['sometimes', 'string'],
|
|
];
|
|
}
|
|
}
|