Handle the deleted event for the Ban model.

@param \Cog\Contracts\Ban\Ban $ban
@return void
501
public function deleted(BanContract $ban): void
    {
        $bannable = $ban->bannable()->withBanned()->first();
        if ($bannable->bans->count() === 0) {
            $bannable->unsetBannedFlag()->save();

            event(new ModelWasUnbanned($bannable));
        }
    }
1011695
public function onBanSelf()
    {
        $rulesToRemove = ['notSubmitterIpHostname'];
        $rules         = (array) array_get($this->rules, 'value', []);

        foreach ($rules as $index => $rule) {
            if (in_array($rule, $rulesToRemove, true)) {
                unset($this->rules['value'][$index]);
            }
        }
    }
82594
public function Ban($UserID, $Unban = FALSE) {
      $this->Permission('Garden.Moderation.Manage');
      
      $User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
      if (!$User)
         throw NotFoundException($User);
      
//      $this->Form = new Gdn_Form();
      
      $UserModel = Gdn::UserModel();

      // Block banning the superadmin or System accounts
      $User = $UserModel->GetID($UserID);
      if (GetValue('Admin', $User) == 2)
         throw ForbiddenException("@You may not ban a System user.");
      elseif (GetValue('Admin', $User))
         throw ForbiddenException("@You may not ban a user with the Admin flag set.");


      if ($this->Form->AuthenticatedPostBack()) {
         if ($Unban) {
            $UserModel->Unban($UserID, array('RestoreContent' => $this->Form->GetFormValue('RestoreContent')));
         } else {
            if (!ValidateRequired($this->Form->GetFormValue('Reason'))) {
               $this->Form->AddError('ValidateRequired', 'Reason');
            }
            if ($this->Form->GetFormValue('Reason') == 'Other' && !ValidateRequired($this->Form->GetFormValue('ReasonText'))) {
               $this->Form->AddError('ValidateRequired', 'Reason Text');
            }

            if ($this->Form->ErrorCount() == 0) {
               if ($this->Form->GetFormValue('Reason') == 'Other')
                  $Reason = $this->Form->GetFormValue('ReasonText');
               else
                  $Reason = $this->Form->GetFormValue('Reason');

               $UserModel->Ban($UserID, array('Reason' => $Reason, 'DeleteContent' => $this->Form->GetFormValue('DeleteContent')));
            }
         }
         
         if ($this->Form->ErrorCount() == 0) {
            // Redirect after a successful save.
            if ($this->Request->Get('Target')) {
               $this->RedirectUrl = $this->Request->Get('Target');
            } elseif ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
               $this->RedirectUrl = Url(UserUrl($User));
            } else {
               $this->JsonTarget('', '', 'Refresh');
            }
         }
      }
      
      $this->SetData('User', $User);
      $this->AddSideMenu();
      $this->Title($Unban ? T('Unban User') : T('Ban User'));
      if ($Unban)
         $this->View = 'Unban';
      $this->Render();
   }
468836
protected function deleteTrigger()
    {
        $this->controlAccess('trigger_delete');

        if ($this->trigger->delete($this->data_trigger['trigger_id'])) {
            $this->redirect('admin/settings/trigger', $this->text('Trigger has been deleted'), 'success');
        }

        $this->redirect('', $this->text('Trigger has not been deleted'), 'warning');
    }
1097278
private function handleDelete(DeleteCommand $command)
    {
        $this->state = ORMInterface::STATE_DELETED;
        $this->dispatch('deleted', new RecordEvent($this, $command));
    }
1236677
public function SaveUser($User, $BannedValue, $Ban = FALSE) {
      $Banned = $User['Banned'];

      if ($Banned == $BannedValue)
         return;
      
      Gdn::UserModel()->SetField($User['UserID'], 'Banned', $BannedValue);

      // Add the activity.
      $ActivityModel = new ActivityModel();
      $Activity = array(
          'ActivityType' => 'Ban',
          'ActivityUserID' => $User['UserID'],
          'RegardingUserID' => Gdn::Session()->UserID,
          'NotifyUserID' => ActivityModel::NOTIFY_MODS
          );
      
      $BannedString = $BannedValue ? 'banned' : 'unbanned';
      if ($Ban) {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was '.$BannedString.' (based on {Data.BanType}: {Data.BanValue}).';
         $Activity['Data'] = ArrayTranslate($Ban, array('BanType', 'BanValue'));
         $Activity['Story'] = $Ban['Notes'];
         $Activity['RecordType'] = 'Ban';
         
         if (isset($Ban['BanID'])) {
            $Activity['BanID'] = $Ban['BanID'];
         }
      } else {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was '.$BannedString.'.';
      }
      $ActivityModel->Save($Activity);
   }
746062
public function handle(RemoveUserCommand $command)
    {
        $user = $command->user;

        event(new UserWasRemovedEvent($user));

        $user->delete();
    }
231853
public function deleteUnused(): void
	{
		/* @var $orm Orm */
		$orm = $this->getRepository()->getModel();
		$resources = [];
		$rules = $orm->acl->findAll();
		foreach ($rules as $rule) {
			/* @var $rule Acl */
			$resources[] = $rule->resource->id;
		}
		if (empty($resources)) {
			$this->connection->query('DELETE FROM %table', $this->getTableName());
		} else {
			$this->connection->query('DELETE FROM %table WHERE [id] NOT IN %i[]', $this->getTableName(), $resources);
		}
	}
160636
public function creating(BanContract $ban): void
    {
        $bannedBy = auth()->user();
        if ($bannedBy && is_null($ban->created_by_type) && is_null($ban->created_by_id)) {
            $ban->fill([
                'created_by_type' => $bannedBy->getMorphClass(),
                'created_by_id' => $bannedBy->getKey(),
            ]);
        }
    }
1020649
public function onAfterDelete() {
		parent::onAfterDelete();
		// Create a basic new environment config from a template
		if($this->config()->get('allow_web_editing') && $this->envFileExists()) {
			unlink($this->getConfigFilename());
		}
	}
195226
public function onDelete(Event\Delete $event)
    {
        $success = $event->getUser()->delete();
        $event->setResult( (bool)$success );
        if( $event->getResult() === false )
        {
            $event->stopPropagation(true);
        }
        return $event;
    }
698749
public function handlePostRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$this->supports($document)) {
            return;
        }

        $oid = spl_object_hash($document);
        $event = $this->deleteEvents[$oid];

        $this->eventDispatcher->dispatch(
            ContentEvents::NODE_POST_DELETE,
            $event
        );

        unset($this->deleteEvents[$oid]);
    }
733727
def ban_delete(self, ban_id, **kwargs):
        ""
        api_path = "/api/v2/bans/{ban_id}"
        api_path = api_path.format(ban_id=ban_id)
        return self.call(api_path, method="DELETE", **kwargs)
421738
public function handle(UnsubscribeSubscriberCommand $command)
    {
        $subscriber = $command->subscriber;

        // First remove subscriptions.
        $subscriber->subscriptions()->delete();

        event(new SubscriberHasUnsubscribedEvent($subscriber));

        // Then remove the subscriber.
        $subscriber->delete();
    }
120912
public function delete(): void
    {
        // 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
        $this->clearHeaders();

        if (!\imap_delete($this->resource->getStream(), $this->getNumber(), \FT_UID)) {
            throw new MessageDeleteException(\sprintf('Message "%s" cannot be deleted', $this->getNumber()));
        }
    }
714997
public function delete()
    {
        if (!$this->isXmlHttpRequest()) {
            throw new \Exception("wrong request mode");
        }

        $deleted = $this->getClassService()->deleteInstance($this->getCurrentInstance());

        $this->returnJson(array(
            'deleted' => $deleted
        ));
    }
532188
public function do_delete($topic)
    {
        /** @var \ManaPHP\DbInterface $db */
        $db = $this->_di->getShared($this->_db);

        $db->delete($this->_source, ['topic' => $topic]);
    }