35 lines
800 B
PHP
35 lines
800 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Front;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class SearchRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Prepare the data for validation.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
protected function prepareForValidation(): void
|
||
|
|
{
|
||
|
|
$this->merge(['page' => (int) $this->page ?: 1]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
$queryKey = trans('front.search.query');
|
||
|
|
$pageKey = trans('front.search.page');
|
||
|
|
|
||
|
|
return [
|
||
|
|
$queryKey => 'required|string|between:3,255',
|
||
|
|
$pageKey => 'required|integer|min:1',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|