<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'type' => 'nullable|string|in:e-invoice,e-archive',
            'status' => 'nullable|string|in:active,inactive,error',
            'is_active' => 'nullable|boolean',
            'is_automatic' => 'nullable|boolean',
            'draw' => 'required|integer',
            'start' => 'required|integer|min:0',
            'length' => 'required|integer|min:1|max:100',
            'order' => 'nullable|array',
            'order.*.column' => 'required_with:order|integer|min:0',
            'order.*.dir' => 'required_with:order|in:asc,desc',
        ];
    }
}
