canDo('checklist.asset.view') && $user->isAdmin()) { return true; } return $asset->user_id == user_id() && $asset->user_type == user_type(); } /** * Determine if the given user can create a asset. * * @param UserPolicy $user * @param Asset $asset * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('checklist.asset.create'); } /** * Determine if the given user can update the given asset. * * @param UserPolicy $user * @param Asset $asset * * @return bool */ public function update(UserPolicy $user, Asset $asset) { if ($user->canDo('checklist.asset.edit') && $user->isAdmin()) { return true; } return $asset->user_id == user_id() && $asset->user_type == user_type(); } /** * Determine if the given user can delete the given asset. * * @param UserPolicy $user * @param Asset $asset * * @return bool */ public function destroy(UserPolicy $user, Asset $asset) { return $asset->user_id == user_id() && $asset->user_type == user_type(); } /** * Determine if the given user can verify the given asset. * * @param UserPolicy $user * @param Asset $asset * * @return bool */ public function verify(UserPolicy $user, Asset $asset) { if ($user->canDo('checklist.asset.verify')) { return true; } return false; } /** * Determine if the given user can approve the given asset. * * @param UserPolicy $user * @param Asset $asset * * @return bool */ public function approve(UserPolicy $user, Asset $asset) { if ($user->canDo('checklist.asset.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $user [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($user, $ability) { if ($user->isSuperuser()) { return true; } } }