modules/admin/controllers/AdsController.php
/**
     * Deletes an existing Ads model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
Deletes an existing Ads model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
@throws NotFoundHttpException if the model cannot be found
Deletes an existing Ads model . If deletion is successful the browser will be redirected to the ' index ' page . @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        $image = $model->image;
        $uploadDirPath = Yii::getAlias('@adsImageRelativePath');
        $uploadThumbDirPath = Yii::getAlias('@adsImageThumbRelativePath');
        if (file_exists($uploadDirPath . '/' . $image) && !empty($image)) {
            unlink($uploadDirPath . '/' . $image);
        }
        if (file_exists($uploadThumbDirPath . '/' . $image) && !empty($image)) {
            unlink($uploadThumbDirPath . '/' . $image);
        }
        if ($model->delete()) {
            Yii::$app->session->setFlash(Growl::TYPE_SUCCESS, "Ads deleted successfully.");
        } else {
            Yii::$app->session->setFlash(Growl::TYPE_DANGER, "Error while deleting Ads.");
        }
        return $this->redirect(['index']);
    }
public function actionDelete ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ image = $ model -> image ; $ uploadDirPath = Yii :: getAlias ( '@adsImageRelativePath' ) ; $ uploadThumbDirPath = Yii :: getAlias ( '@adsImageThumbRelativePath' ) ; if ( file_exists ( $ uploadDirPath . '/' . $ image ) && ! empty ( $ image ) ) { unlink ( $ uploadDirPath . '/' . $ image ) ; } if ( file_exists ( $ uploadThumbDirPath . '/' . $ image ) && ! empty ( $ image ) ) { unlink ( $ uploadThumbDirPath . '/' . $ image ) ; } if ( $ model -> delete ( ) ) { Yii :: $ app -> session -> setFlash ( Growl :: TYPE_SUCCESS , " Ads deleted successfully. " ) ; } else { Yii :: $ app -> session -> setFlash ( Growl :: TYPE_DANGER , " Error while deleting Ads. " ) ; } return $ this -> redirect ( [ 'index' ] ) ; }
Deletes an existing Ads model.
Deletes an existing Ads model .
// unlink images with thumb