['required', 'string', 'min:2', 'max:100'], 'type' => ['required', Rule::in(['meals', 'users'])], 'page' => ['sometimes', 'integer', 'min:1'], 'per_page' => ['sometimes', 'integer', 'min:1', 'max:50'], ]; } protected function prepareForValidation(): void { if ($this->has('q')) { $this->merge([ 'q' => trim((string) $this->input('q')), ]); } } }