<?php

namespace App\Services\System\Setting;

use App\Settings\HrSettings;

class HrSettingService
{
    public function hrData(): array
    {
        $settings = app(HrSettings::class);

        return [
            'scheduled_check_in_time' => $settings->scheduled_check_in_time,
            'scheduled_check_out_time' => $settings->scheduled_check_out_time,
            'late_penalty_amount' => $settings->late_penalty_amount,
            'absent_penalty_amount' => $settings->absent_penalty_amount,
        ];
    }

    public function updateHr(array $validated): void
    {
        $settings = app(HrSettings::class);

        $settings->scheduled_check_in_time = $validated['scheduled_check_in_time'];
        $settings->scheduled_check_out_time = $validated['scheduled_check_out_time'];
        $settings->late_penalty_amount = (int) $validated['late_penalty_amount'];
        $settings->absent_penalty_amount = (int) $validated['absent_penalty_amount'];
        $settings->save();
    }
}
