checkResourcePermission($this->resourceType, $this->resourceValue, 'view'); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'sort' => ['sometimes', 'string', 'in:id,migration,batch'], 'direction' => ['sometimes', 'string', 'in:asc,desc'], 'search' => ['sometimes', 'nullable', 'string', 'max:255'], ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return [ 'sort.in' => 'The sort field must be either id, migration, or batch.', 'direction.in' => 'The direction must be either ascending or descending.', 'search.max' => 'The search term cannot exceed 255 characters.', ]; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'sort' => 'sort field', 'direction' => 'sort direction', 'search' => 'search term', ]; } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { // Ensure sort and direction have default values if not provided $this->merge([ 'sort' => $this->input('sort', 'id'), 'direction' => $this->input('direction', 'desc'), ]); } }