<?php

namespace App\Modules\HR\Attendance\Services;

use App\Modules\HR\Attendance\Models\Holiday;
use App\Modules\HR\Attendance\Repositories\HolidayRepository;

class HolidayService
{
    public function __construct(private readonly HolidayRepository $holidays) {}

    public function save(int $tenantId, array $data, ?Holiday $holiday = null): Holiday
    {
        $data['is_recurring_yearly'] = (bool) ($data['is_recurring_yearly'] ?? false);
        $data['is_active'] = (bool) ($data['is_active'] ?? false);

        return $this->holidays->save($tenantId, $data, $holiday);
    }

    public function delete(Holiday $holiday): void
    {
        $this->holidays->delete($holiday);
    }
}
