<?php
namespace Modules\Employee\Services;

use Modules\Employee\Repositories\BloodRepository;
use Modules\Employee\DTO\EmployeeSettingFilter;
use Illuminate\Support\Facades\DB;
use Modules\Employee\Models\Blood;

class BloodService
{
    protected $bloodRepo;

    public function __construct(BloodRepository $bloodRepo) {
        $this->bloodRepo = $bloodRepo;
    }

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

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

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

    public function update(Blood $blood, array $data)
    {
        return DB::transaction(function () use ($blood, $data) {
            return $this->bloodRepo->update($blood, $data);
        });
    }

    public function updateStatus(Blood $blood, array $status)
    {
        return DB::transaction(function () use ($blood, $status) {
            return $this->bloodRepo->updateStatus($blood, $status);
        });
    }

}
