service-captcha/app/Http/Requests/Private/Users/IndexRequest.php

31 lines
723 B
PHP
Raw Normal View History

2023-08-01 22:04:35 +06:00
<?php declare(strict_types=1);
namespace App\Http\Requests\Private\Users;
use App\Contracts\FormRequestDto;
use App\Dto\Builder\User;
use App\Dto\Request\Private\User\Index;
use Illuminate\Foundation\Http\FormRequest;
final class IndexRequest extends FormRequest implements FormRequestDto
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
$this->redirect = route('users.index');
return [
'page' => ['nullable', 'numeric', 'min:1']
];
}
public function getDto(): Index
{
return new Index(
userBuilderDto: new User(),
page: (int) $this->input('page', 1)
);
}
}