<?php

namespace Modules\HR\Http\Requests\TaxSlab;

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

class StoreTaxSlabRequest extends FormRequest
{
    use FailedValidation;
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'fiscal_year_id' => ['required', 'exists:fiscal_years,id'],
            'min_income' => ['required', 'numeric', 'min:0'],
            'max_income' => ['required', 'numeric', 'gt:min_income'],
            'tax_type' => [
                'required',
                Rule::in(TaxSlabTypeEnum::casesAsArray())
            ],
            'tax_value' => ['required', 'numeric', 'min:0'],
            'is_disabled' => ['sometimes', 'boolean'],
            'status' => ['sometimes',
            Rule::in(StatusEnum::casesAsArray())]
        ];
    }

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