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