<?php

namespace Modules\HR\Http\Requests\SalaryStructure;

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

class UpdateSalaryStructureRequest extends FormRequest
{
    use FailedValidation;

    public function rules(): array
    {
        return [
            'employee_id' => [
                'required',
                'exists:employees,id',
            ],

            'name' => [
                'required',
                'string',
                'max:255',
            ],

            'effective_from' => [
                'required',
                'date',
            ],

            'effective_to' => [
                'nullable',
                'date',
                'after_or_equal:effective_from',
            ],

            'is_active' => [
                'required',
                'boolean',
            ],

            'is_locked' => [
                'required',
                'boolean',
            ],

            'status' => [
                'required',
                'string',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }

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