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