<?php

namespace App\Http\Requests\Admin;

use App\Models\CancellationRequest;
use Illuminate\Foundation\Http\FormRequest;

class CancellationRequestRecordsRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return $this->user()->can('viewAny', CancellationRequest::class);
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'draw' => 'required|integer',
            'start' => 'required|integer|min:0',
            'length' => 'required|integer|min:1|max:100',
            'search' => 'nullable|array',
            'search.value' => 'nullable|string',
            'order' => 'nullable|array',
            'order.*.column' => 'required_with:order|integer',
            'order.*.dir' => 'required_with:order|in:asc,desc',
        ];
    }
}
