<?php

namespace Modules\HR\Http\Requests\AttendancePolicy;

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

class StoreAttendancePolicyRequest extends FormRequest
{
    use FailedValidation;
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'name' => [
                'required',
                'string',
                'max:255',
                'unique:attendance_policies,name',
            ],
            'late_grace_minutes' => [
                'required',
                'integer',
                'min:0',
            ],
            'max_late_count' => [
                'required',
                'integer',
                'min:0',
            ],
            'half_day_after_minutes' => [
                'required',
                'integer',
                'min:0',
            ],
            'absent_after_minutes' => [
                'required',
                'integer',
                'min:0',
            ],
            'auto_absent' => [
                'required',
                'boolean',
            ],
            'allow_overtime' => [
                'required',
                'boolean',
            ],
            'status' => [
                'required',
                'string',
                Rule::in(StatusEnum::casesAsArray()),
            ],
        ];
    }

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