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