<?php

namespace App\Modules\Exports\Requests;

use App\Modules\Exports\Support\ExportType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreExportRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('exports.access') ?? false;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'type' => ['required', 'string', Rule::in(ExportType::all())],
            'filters' => ['nullable', 'array'],
            'filters.from' => ['nullable', 'date'],
            'filters.to' => ['nullable', 'date'],
            'filters.date_from' => ['nullable', 'date'],
            'filters.date_to' => ['nullable', 'date'],
            'filters.type' => ['nullable', 'string', 'max:64'],
            'filters.severity' => ['nullable', 'string', 'max:32'],
            'filters.status' => ['nullable', 'string', 'max:64'],
            'filters.employee_id' => ['nullable', 'integer'],
            'filters.department_id' => ['nullable', 'integer'],
            'filters.vacancy_id' => ['nullable', 'integer'],
            'filters.recruiter_id' => ['nullable', 'integer'],
            'filters.report_type' => ['nullable', 'string', 'max:64'],
        ];
    }
}
