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