ldc-ovoteam/app/Http/Requests/Back/Recipes/IndexRecipeRequest.php
Jérémy Munsch bc69c9f64d
feat(products): implement GetBoPaginatedProductsQuery and input/output classes
feat(recipes): implement GetBoPaginatedRecipesQuery and input/output classes

feat(requests): add table parameter resolution for products and recipes
2026-11-05 12:17:58 +01:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Back\Recipes;
use App\Cqs\Queries\Recipes\GetBoPaginatedRecipesQueryInput;
use App\Http\Requests\Back\Concerns\ResolvesBoTableParams;
use App\Services\AdminAuthService;
use Illuminate\Foundation\Http\FormRequest;
class IndexRecipeRequest extends FormRequest
{
use ResolvesBoTableParams;
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;
}
public function toGetBoPaginatedRecipesQueryInput(): GetBoPaginatedRecipesQueryInput
{
return new GetBoPaginatedRecipesQueryInput(
pagination: $this->getTablePagination(),
search: $this->getSearchValue(),
sortCol: $this->getTableSortCol(),
sortDirection: $this->getTableSortDirection(),
isTrash: $this->routeIs('back.recipes.trash'),
);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Validation\Rule|array<mixed>|string>
*/
public function rules(): array
{
return [
'search' => ['sometimes', 'string'],
];
}
}