<?php

namespace Bixo\Shop\Policies;

use Bixo\Shop\Models\SparePart;
use Illuminate\Foundation\Auth\User as Authenticatable;

trait SparePartWorkflow
{

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

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

        return false;
    }

}