<?php
namespace Modules\Employee\Services;

use Modules\Employee\Repositories\BranchRepository;
use Modules\Employee\DTO\EmployeeSettingFilter;
use Illuminate\Support\Facades\DB;
use Modules\Employee\Models\Branch;

class BranchService
{
    protected $branchRepo;

    public function __construct(BranchRepository $branchRepo) {
        $this->branchRepo = $branchRepo;
    }

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

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

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

    public function update(Branch $branch, array $data)
    {
        return DB::transaction(function () use ($branch, $data) {
            return $this->branchRepo->update($branch, $data);
        });
    }

    public function updateStatus(Branch $branch, array $status)
    {
        return DB::transaction(function () use ($branch, $status) {
            return $this->branchRepo->updateStatus($branch, $status);
        });
    }

}
