<?php

namespace App\Http\Requests\Hr;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreAttendanceCorrectionRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->hasPermission('attendance.view') === true;
    }

    public function rules(): array
    {
        return [
            'requested_check_in' => ['nullable', 'date'],
            'requested_check_out' => ['nullable', 'date', 'after:requested_check_in'],
            'requested_status' => ['nullable', Rule::in(['present', 'absent', 'late', 'early_leave', 'half_day', 'on_leave', 'holiday', 'weekly_off', 'work_from_home', 'business_visit'])],
            'reason' => ['required', 'string', 'min:5', 'max:2000'],
        ];
    }
}
