<?php

namespace App\Http\Requests\Admin\System\Setting;

use App\Enums\Permission;
use Illuminate\Foundation\Http\FormRequest;

class HrSettingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can(Permission::SETTINGS_UPDATE->value) ?? false;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'scheduled_check_in_time' => ['required', 'string', 'max:5', 'regex:/^\d{2}:\d{2}$/'],
            'scheduled_check_out_time' => ['required', 'string', 'max:5', 'regex:/^\d{2}:\d{2}$/'],
            'late_penalty_amount' => ['required', 'integer', 'min:0'],
            'absent_penalty_amount' => ['required', 'integer', 'min:0'],
        ];
    }

    /**
     * @return array<string, string>
     */
    public function attributes(): array
    {
        return [
            'scheduled_check_in_time' => 'jam masuk kerja',
            'scheduled_check_out_time' => 'jam pulang kerja',
            'late_penalty_amount' => 'denda keterlambatan',
            'absent_penalty_amount' => 'denda bolos',
        ];
    }
}
