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