<?php

namespace Modules\HR\Services;

use Illuminate\Support\Facades\DB;
use Modules\HR\DTO\HrSettingFilter;
use Modules\HR\Models\FestivalBonusPolicy;
use Modules\HR\Repositories\FestivalBonusPolicyRepository;

class FestivalBonusPolicyService
{
    public function __construct(
        protected FestivalBonusPolicyRepository $festivalBonusPolicyRepo
    ) {}

    public function list(HrSettingFilter $filter)
    {

        $columns = ['id','festival_name','eligibility','religion_id','bonus_type','bonus_value','minimum_service_days','status'];
        $relations = ['religion:id,name'];
        return $this->festivalBonusPolicyRepo->all($filter, $columns, $relations);
    }

    public function show($id)
    {
        return $this->festivalBonusPolicyRepo->find($id);
    }

    public function store(array $data)
    {
        return DB::transaction(function () use ($data) {
            return $this->festivalBonusPolicyRepo->create($data);
        });
    }

    public function update(FestivalBonusPolicy $festivalBonusPolicy, array $data)
    {
        return DB::transaction(function () use ($festivalBonusPolicy, $data) {
            return $this->festivalBonusPolicyRepo->update($festivalBonusPolicy, $data);
        });
    }

    public function updateStatus(FestivalBonusPolicy $festivalBonusPolicy, array $status)
    {
        return DB::transaction(function () use ($festivalBonusPolicy, $status) {
            return $this->festivalBonusPolicyRepo->updateStatus($festivalBonusPolicy, $status);
        });
    }
}
