Deletes an existing Admin model.
If deletion is successful, the browser will be redirected to the 'index' page.

@param integer $id
@return mixed
@throws NotFoundHttpException
@throws \Exception
@throws \Throwable
@throws \yii\db\StaleObjectException
773158
public function actionDelete($id)
    {
        if (Admin::find()->count() == 1) {
            Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'This is the last administrator, delete can not manage the system, it can not be deleted!'));
            return $this->redirect(['index']);
        }
        $this->findModel($id)->delete();
        Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Delete success.'));
        return $this->redirect(['index']);
    }
1364712
public function deleteAction($id)
    {
        $instance = $this->getManager()->find($id);
        if($instance) {
            $this->getManager()->delete($instance);
            $this->get('session')->getFlashBag()->add('success', 'Instance Redis has been deleted successfully');
        }else {
            $this->get('session')->getFlashBag()->add('error', 'This instance does not exist');
        }
        
        return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
    }
220171
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        $model->pageSize = intval($this->module->params['pageSizeAdmin']);
        $page = $model->calcPage();
        $result = $model->delete();
        if ($result) {
            Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'User #{id} deleted.', ['id' => $id]));
        } else {
            Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'Deletion user #{id} fail.', ['id' => $id]));
        }
        return $this->redirect(['index', 'id' => $id, 'page' => $page]);
    }
908421
public function delete(string $id)
    {
        $this->request->allowMethod(['post', 'delete']);
        $model = $this->loadModel();
        $entity = $model->get($id);

        if ($model->delete($entity)) {
            $this->Flash->success((string)__('The record has been deleted.'));
        } else {
            $this->Flash->error((string)__('The record could not be deleted. Please, try again.'));
        }

        $url = $this->referer();

        if (false !== strpos($url, $id)) {
            $url = ['action' => 'index'];
        }

        return $this->redirect($url);
    }
1241688
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        if ($model->deleteWithRelated()) {
            delete_media_path($model->path);
            set_flash_success_delete_content();
        } else {
            set_flash_error_delete_content();
        }

        return $this->goBack(request()->referrer);
    }
875119
public function delete(string $id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $role = $this->Roles->get($id);
        if ($this->Roles->delete($role)) {
            $this->Flash->success((string)__('The role has been deleted.'));
        } else {
            $this->Flash->error((string)__('The role could not be deleted. Please, try again.'));
        }

        return $this->redirect(['action' => 'index']);
    }
1030052
public function actionRemove(int $id)
    {

        RelatedProduct::deleteAll(['id' => $id]);

        return $this->redirect(\Yii::$app->request->referrer);
    }
841239
public function deleteAction($id)
    {
        try {
            $this->getManager()->delete($id);
            $view = $this->view($id, 204);
        } catch (FilterNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        }

        return $this->handleView($view);
    }
1259047
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        Yii::$app->getAuthManager()->remove($model->item);
        Helper::invalidate();

        return $this->redirect(['index']);
    }
233682
public function actionDelete($id)
    {
        $emailTemplate = $this->loadModel($id);
        $emailTemplate->delete();
        $this->redirect(Yii::app()->user->getState('index.emailTemplate', array('template/index')));
    }
806564
public function delete($id)
    {
        if ($this->hasDeleteTrait($this->modelInstance)) {
            return $this->destroy($id);
        }

        return $this->modelInstance->destroy($id);
    }
598631
public function destroy($id)
    {
        $result = $this->service->destroy($id);

        if ($result) {
            return redirect('admin/features')->with('message', 'Successfully deleted');
        }

        return redirect('admin/features')->with('errors', ['Failed to delete']);
    }
100445
public function deleteAction($id)
    {
        $manager = $this->getTaskManager();
        $manager->remove($id);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
934136
public function actionDelete($id = null)
    {
        $model = Subscription::find()->where(['id' => (int)$id, 'user_id' => User::loggedId()])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Subscription with this ID.'));
            return $this->redirect(['profile/subscriptions']);
        }
        if ($model->delete()) {
            $this->module->podiumCache->deleteElement('user.subscriptions', User::loggedId());
            $this->success(Yii::t('podium/flash', 'Thread has been unsubscribed.'));
        } else {
            Log::error('Error while deleting subscription', $model->id, __METHOD__);
            $this->error(Yii::t('podium/flash', 'Sorry! There was some error while deleting the subscription.'));
        }
        return $this->redirect(['profile/subscriptions']);
    }
654604
public function delete($id)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $sql = 'DELETE from :table WHERE id=:id';
        $sql = str_replace(':table', $this->tableName, $sql);

        $statement = $connection->prepare($sql);
//        $statement->bindParam(':table',  $this->tableName);
        $statement->bindParam(':id', $id, \PDO::PARAM_INT);

        $queryWasSuccessful = $statement->execute();
        return $queryWasSuccessful;
    }
1077787
public function deleteAction($id)
    {
        $delete = $this->getUserManager()->delete();
        $view = $this->responseDelete($id, $delete);

        return $this->handleView($view);
    }
1037543
public function actionDelete($id)
    {
        if (!\Yii::$app->user->can('delete'))
            throw new ForbiddenHttpException(Module::t('core', 'Access denied.'));

        $model = $this->findModel($id);

        // delete selected tag in all posts
        foreach(Post::find()->where(['like', 'tags', $model->name])->all() as $post) {
            $a = $model->string2array($post->tags);
            $i = array_search($model->name, $a);
            unset($a[$i]);
            $post->tags = $model->array2string($a);
            $post->save();
        }
        $model->delete();

        return $this->redirect(['index']);
    }