<?php

namespace Modules\SpecialAttendance\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreTardyRecordRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'date' => 'required|date',
            'user_id' => 'required|integer|exists:users,id',
            'tardy_rule_id' => 'required|integer|exists:tardy_rules,id',
            'tardy_type' => 'required|string|in:Check In,Check Out',
            'tardy_minutes' => 'required|integer|min:1',
            'is_emergency' => 'nullable|in:0,1',
            'is_notified' => 'nullable|in:0,1',
            'reason' => 'nullable|string|max:255',
        ];
    }

    public function messages()
    {
        return [
            'date.required' => _trans('validation.The date is required.'),
            'date.date' => _trans('validation.The date must be a valid date.'),
            'user_id.required' => _trans('validation.The user is required.'),
            'user_id.integer' => _trans('validation.The user ID must be an integer.'),
            'user_id.exists' => _trans('validation.The selected user does not exist.'),
            'tardy_rule_id.required' => _trans('validation.The tardy rule is required.'),
            'tardy_rule_id.integer' => _trans('validation.The tardy rule ID must be an integer.'),
            'tardy_rule_id.exists' => _trans('validation.The selected tardy rule does not exist.'),
            'tardy_type.required' => _trans('validation.The tardy type is required.'),
            'tardy_type.string' => _trans('validation.The tardy type must be a string.'),
            'tardy_type.in' => _trans('validation.The tardy type must be either Check In or Check Out.'),
            'tardy_minutes.required' => _trans('validation.The tardy minutes are required.'),
            'tardy_minutes.integer' => _trans('validation.The tardy minutes must be an integer.'),
            'tardy_minutes.min' => _trans('validation.The tardy minutes must be at least 1.'),
            'is_emergency.in' => _trans('validation.The emergency status must be 0 or 1.'),
            'is_notified.in' => _trans('validation.The notified status must be 0 or 1.'),
            'reason.string' => _trans('validation.The reason must be a string.'),
            'reason.max' => _trans('validation.The reason must not exceed 255 characters.'),
        ];
    }
}
