<?php

namespace Modules\Employee\Http\Requests\SalaryGrade;

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

class StoreSalaryGradeRequest extends FormRequest
{
    use FailedValidation;
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => [
                'required',
                'string',
                'max:255',
                'unique:salary_grades,name',
            ],
            'min_salary' => [
                    'nullable',
                    'numeric',
                    'min:0',
                ],
            'max_salary' => [
                    'nullable',
                    'numeric',
                    'min:0',
                    'gte:min_salary',
                ],
            'status' => [
                'required',
                'string',
                'in:' . implode(',', StatusEnum::casesAsArray()),
            ],
        ];
    }

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