<?php

namespace App\Http\Requests\V1\AiReport;

use App\Http\Requests\Traits\HasPagination;
use App\Models\Tenants\AiReport;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AiReportListRequest extends FormRequest
{
    use HasPagination;

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'per_page' => ['nullable', 'integer', 'min:1'],
            'report_type' => ['nullable', 'string', Rule::in(array_keys(AiReport::REPORT_TYPES))],
            'status' => ['nullable', 'string', Rule::in(array_keys(AiReport::STATUSES))],
            'start_date' => ['nullable', 'date'],
            'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
        ];
    }

    public function messages(): array
    {
        return [
            'report_type.in' => __('validation.in', ['attribute' => __('validation.attributes.report_type')]),
            'status.in' => __('validation.in', ['attribute' => __('validation.attributes.status')]),
            'end_date.after_or_equal' => __('validation.after_or_equal', [
                'attribute' => __('validation.attributes.end_date'),
                'date' => __('validation.attributes.start_date'),
            ]),
        ];
    }
}
