<?php

namespace Bixo\Account\Policies;

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

trait PayrecWorkflow
{

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

}