<?php

namespace Modules\Employee\Http\Requests\EmployeeHolidayGroup;

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

class TransferEmployeeHolidayGroupRequest extends FormRequest
{
    use FailedValidation;

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'employee_id' => [
                'required',
                'integer',
                'exists:employees,id',
            ],
            'new_holiday_group_id' => [
                'required',
                'integer',
                'exists:holiday_groups,id',
                function ($attribute, $value, $fail) {
                    $employeeId = $this->input('employee_id');
                    if (!$employeeId) return;
                }
            ],
            'effective_date' => [
                'required',
                'date',
                'date_format:Y-m-d',
            ],
            'status' => [
                'required',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }


}
