<?php
namespace Modules\Employee\Services;

use Modules\Employee\Repositories\StaffTypeRepository;
use Modules\Employee\DTO\EmployeeSettingFilter;
use Illuminate\Support\Facades\DB;
use Modules\Employee\Models\StaffType;

class StaffTypeService
{
    protected $staffTypeRepo;

    public function __construct(StaffTypeRepository $staffTypeRepo) {
        $this->staffTypeRepo = $staffTypeRepo;
    }

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

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

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

    public function update(StaffType $staffType, array $data)
    {
        return DB::transaction(function () use ($staffType, $data) {
            return $this->staffTypeRepo->update($staffType, $data);
        });
    }

    public function updateStatus(StaffType $staffType, array $status)
    {
        return DB::transaction(function () use ($staffType, $status) {
            return $this->staffTypeRepo->updateStatus($staffType, $status);
        });
    }

}
