Beispiel #1
0
 public function actionDelete($id)
 {
     PageSelfRels::updateAll(['parent_page_id' => 0], 'parent_page_id = ' . $id);
     PageSelfRels::deleteAll(['page_id' => $id]);
     $images = PageImageRel::findAll(['page_id' => $id]);
     if (!empty($images)) {
         foreach ($images as $key => $value) {
             unlink(\Yii::getAlias('@webroot') . '/uploads/' . $value->image);
         }
     }
     PageImageRel::deleteAll(['page_id' => $id]);
     PageCategoryRel::deleteAll(['page_id' => $id]);
     Post::deleteAll(['page_id' => $id]);
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
Beispiel #2
0
 public function getPage_image_rel()
 {
     return $this->hasMany(PageImageRel::className(), ['page_id' => 'id']);
 }