Files
backend-mm/app/Http/Requests/Api/V1/Product/BasicProductIndexRequest.php
2025-09-25 03:03:31 +05:00

34 lines
840 B
PHP

<?php
namespace App\Http\Requests\Api\V1\Product;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class BasicProductIndexRequest 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,
]);
}
}