<?php

namespace App\Modules\HR\Recruitment\Requests;

use App\Modules\HR\Recruitment\Support\RecruitmentReportType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreRecruitmentReportSavedFilterRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('recruitment.reports.view') ?? false;
    }

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:120'],
            'report_type' => ['required', 'string', Rule::in(RecruitmentReportType::all())],
            'is_default' => ['sometimes', 'boolean'],
            'date_from' => ['nullable', 'date'],
            'date_to' => ['nullable', 'date', 'after_or_equal:date_from'],
            'department_id' => ['nullable', 'integer', 'exists:departments,id'],
            'vacancy_id' => ['nullable', 'integer', 'exists:recruitment_vacancies,id'],
            'recruiter_id' => ['nullable', 'integer', 'exists:users,id'],
            'status' => ['nullable', 'string', 'max:64'],
        ];
    }
}
