<?php

namespace Bixo\Account\Policies;

use Bixo\Account\Models\Costcenter;
use Illuminate\Foundation\Auth\User as Authenticatable;

trait CostcenterWorkflow
{

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function approve(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.approve')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function submit(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.submit')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function publish(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.publish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unpublish(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.unpublish')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function archive(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.archive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function unarchive(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.unarchive')) {
            return true;
        }

        return false;
    }

    /**
     * Determine if the given user can approve the given costcenter.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function reject(Authenticatable $user, Costcenter $costcenter)
    {
        if ($user->canDo('account.costcenter.reject')) {
            return true;
        }

        return false;
    }

}