<?php namespace Bixo\Account\Policies; use Bixo\Account\Models\Invoice; use Illuminate\Foundation\Auth\User as Authenticatable; trait InvoiceWorkflow { /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function approve(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.approve')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function submit(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.submit')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function publish(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.publish')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function unpublish(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.unpublish')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function archive(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.archive')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function unarchive(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.unarchive')) { return true; } return false; } /** * Determine if the given user can approve the given invoice. * * @param Authenticatable $user * * @return bool */ public function reject(Authenticatable $user, Invoice $invoice) { if ($user->canDo('account.invoice.reject')) { return true; } return false; } }