controllers/AdminController.php
public function actionDelete($id, $page = 1)
    {
        $model = $this->findModel($id);
/* moved to model:
        $subdir = $this->module->model('News')->getImageSubdir($model->id);
        $fullDir = $this->uploadsNewsDir . '/' . $subdir;//var_dump($fullDir);exit;
        if (is_dir($fullDir)) {
            @FileHelper::removeDirectory($fullDir);
        }
*/
        $model->delete(); // images and i18n-deletions also in main model

        Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Record with ID={id} delete success', ['id' => $id]));

        $searchFormName = basename(NewsSearch::className());
        $paramSort = Yii::$app->request->get($searchFormName, []);
        foreach ($paramSort as $key => $val) {
            if (empty($val)) unset($paramSort[$key]);
        }
        return $this->redirect(['index',
            'page' => $page,
            $searchFormName => $paramSort,
            'sort' => $model->orderBy,
        ]);
    }
public function actionDelete($id, $page = 1)
    {
        $model = $this->findModel($id);
/* moved to model:
        $subdir = $this->module->model('News')->getImageSubdir($model->id);
        $fullDir = $this->uploadsNewsDir . '/' . $subdir;//var_dump($fullDir);exit;
        if (is_dir($fullDir)) {
            @FileHelper::removeDirectory($fullDir);
        }
*/
        $model->delete(); // images and i18n-deletions also in main model

        Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Record with ID={id} delete success', ['id' => $id]));

        $searchFormName = basename(NewsSearch::className());
        $paramSort = Yii::$app->request->get($searchFormName, []);
        foreach ($paramSort as $key => $val) {
            if (empty($val)) unset($paramSort[$key]);
        }
        return $this->redirect(['index',
            'page' => $page,
            $searchFormName => $paramSort,
            'sort' => $model->orderBy,
        ]);
    }
public function actionDelete ( $ id , $ page = 1 ) { $ model = $ this -> findModel ( $ id ) ; /* moved to model:
        $subdir = $this->module->model('News')->getImageSubdir($model->id);
        $fullDir = $this->uploadsNewsDir . '/' . $subdir;//var_dump($fullDir);exit;
        if (is_dir($fullDir)) {
            @FileHelper::removeDirectory($fullDir);
        }
*/ $ model -> delete ( ) ; // images and i18n-deletions also in main model Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( $ this -> tcModule , 'Record with ID={id} delete success' , [ 'id' => $ id ] ) ) ; $ searchFormName = basename ( NewsSearch :: className ( ) ) ; $ paramSort = Yii :: $ app -> request -> get ( $ searchFormName , [ ] ) ; foreach ( $ paramSort as $ key => $ val ) { if ( empty ( $ val ) ) unset ( $ paramSort [ $ key ] ) ; } return $ this -> redirect ( [ 'index' , 'page' => $ page , $ searchFormName => $ paramSort , 'sort' => $ model -> orderBy , ] ) ; }
Deletes an existing News model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
Deletes an existing News model . If deletion is successful the browser will be redirected to the index page .