<?php

namespace Bixo\Payment\Policies;

use Bixo\Payment\Models\Payment;
use Illuminate\Foundation\Auth\User as Authenticatable;

trait PaymentWorkflow
{

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

}