<?php

namespace Modules\HR\Http\Requests\HolidayGroup;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Core\Enums\StatusEnum;
use Modules\Core\Traits\FailedValidation;

class UpdateHolidayGroupRequest extends FormRequest
{
    use FailedValidation;

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        $holidayGroupId = $this->route('holiday_group');

        return [
            'name' => [
                'required',
                'string',
                'max:255',
                Rule::unique('holiday_groups', 'name')->ignore($holidayGroupId),
            ],
            'description' => [
                'nullable',
                'string',
            ],

            'status' => [
                'required',
                'string',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }
}
