public function actionDelete($id)
 {
     $news = $this->findModel($id);
     if (Yii::$app->user->identity->level > 1 or $news->id_author == Yii::$app->user->identity->id) {
         $id_cat = $news->id_category;
         if ($news->id_img != null) {
             $imgLoad = imgLoad::findOne($news->id_img);
             $imgLoad->deleteDir($imgLoad->id_new);
             $imgLoad->delete();
         }
         $news->delete();
         return $this->redirect(['/news/index?id=' . $id_cat]);
     }
 }
Ejemplo n.º 2
0
 public function getImg($id)
 {
     return imgLoad::findOne($id);
 }