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