backend/controllers/PostController.php
/**
     * Deletes an existing Post model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     *
     * @param integer $id
     * @throws \Exception
     * @throws \yii\web\ForbiddenHttpException
     * @throws \yii\web\NotFoundHttpException
     * @return mixed
     */
Deletes an existing Post model.
If deletion is successful, the browser will be redirected to the 'index' page.


Deletes an existing Post model . If deletion is successful the browser will be redirected to the ' index ' page .
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        $this->getPermission($model);
        $terms = $model->terms;
        if ($model->delete()) {
            foreach ($terms as $term) {
                $term->updateAttributes(['count' => --$term->count]);
            }
        }
        return $this->redirect(['index', 'type' => $model->type]);
    }
public function actionDelete ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ this -> getPermission ( $ model ) ; $ terms = $ model -> terms ; if ( $ model -> delete ( ) ) { foreach ( $ terms as $ term ) { $ term -> updateAttributes ( [ 'count' => -- $ term -> count ] ) ; } } return $ this -> redirect ( [ 'index' , 'type' => $ model -> type ] ) ; }
Deletes an existing Post model.
Deletes an existing Post model .