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