canDo('favourite.favourite.view') && $authUser->isAdmin()) { return true; } return $favourite->user_id == user_id() && $favourite->user_type == user_type(); } /** * Determine if the given user can create a favourite. * * @param UserPolicyInterface $authUser * * @return bool */ public function create(UserPolicyInterface $authUser) { return $authUser->canDo('favourite.favourite.create'); } /** * Determine if the given user can update the given favourite. * * @param UserPolicyInterface $authUser * @param Favourite $favourite * * @return bool */ public function update(UserPolicyInterface $authUser, Favourite $favourite) { if ($authUser->canDo('favourite.favourite.edit') && $authUser->isAdmin()) { return true; } return $favourite->user_id == user_id() && $favourite->user_type == user_type(); } /** * Determine if the given user can delete the given favourite. * * @param UserPolicyInterface $authUser * * @return bool */ public function destroy(UserPolicyInterface $authUser, Favourite $favourite) { return $favourite->user_id == user_id() && $favourite->user_type == user_type(); } /** * Determine if the given user can verify the given favourite. * * @param UserPolicyInterface $authUser * * @return bool */ public function verify(UserPolicyInterface $authUser, Favourite $favourite) { if ($authUser->canDo('favourite.favourite.verify')) { return true; } return false; } /** * Determine if the given user can approve the given favourite. * * @param UserPolicyInterface $authUser * * @return bool */ public function approve(UserPolicyInterface $authUser, Favourite $favourite) { if ($authUser->canDo('favourite.favourite.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; } } }