src/admin/controllers/AdminController.php
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']);
    }
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']);
    }
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' ] ) ; }
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
Deletes an existing Admin model . If deletion is successful the browser will be redirected to the index page .