public function actionDelete($document_id) { $model = Document::findOne($document_id); if (is_null($model)) { throw new \yii\web\HttpException(404, Yii::t('burivuh', 'The document does not exist')); } if (isset($_POST['document_id'])) { $category = Category::findOne($model->category_id); $model->delete(); $redirect = ['/burivuh/category/index']; if (!is_null($category)) { $redirect = $category->url; } $this->redirect($redirect); } return $this->render('delete', ['model' => $model]); }
public function actionDelete($category_id) { $model = Category::findOne($category_id); if (is_null($model)) { throw new \yii\web\HttpException(404, Yii::t('burivuh', 'The category does not exist')); } if (isset($_POST['category_id'])) { $parent = $model->parent; $model->delete(); $redirect = ['index']; if (!is_null($parent)) { $redirect = $parent->url; } $this->redirect($redirect); } return $this->render('delete', ['model' => $model]); }
public function getChildrenCategory() { return $this->hasMany(Category::className(), ['parent_id' => 'category_id']); }
public function getCategory() { return $this->hasOne(Category::className(), ['category_id' => 'category_id']); }