wip
This commit is contained in:
33
app/Http/Requests/Api/V1/Product/ProductIndexRequest.php
Normal file
33
app/Http/Requests/Api/V1/Product/ProductIndexRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Api\V1\Product;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProductIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'lang' => ['nullable', 'string', Rule::in(array_keys(config('app.locales')))],
|
||||
'perPage' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a passed validation attempt.
|
||||
*/
|
||||
protected function passedValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'lang' => $this->lang ?: config('app.locale'),
|
||||
'perPage' => $this->perPage ?: 6,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user