<?php
namespace Modules\Employee\Services;

use Modules\Employee\Repositories\TerminationRepository;
use Modules\Employee\DTO\EmployeeSettingFilter;
use Illuminate\Support\Facades\DB;
use Modules\Employee\Models\Termination;

class TerminationService
{
    protected $terminationRepo;

    public function __construct(TerminationRepository $terminationRepo) {
        $this->terminationRepo = $terminationRepo;
    }

    public function list(EmployeeSettingFilter $filter)
    {
        return $this->terminationRepo->all($filter);
    }

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

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

    public function update(Termination $termination, array $data)
    {
        return DB::transaction(function () use ($termination, $data) {
            return $this->terminationRepo->update($termination, $data);
        });
    }

    public function updateStatus(Termination $termination, array $status)
    {
        return DB::transaction(function () use ($termination, $status) {
            return $this->terminationRepo->updateStatus($termination, $status);
        });
    }

}
