/** * Deletes an existing Board model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); $forum_url = $model->forum['forum_url']; Thread::deleteAll(['board_id' => $model->id]); $model->delete(); Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Deleted successfully.')); return $this->redirect(['/forum/forum/update', 'id' => $forum_url, 'action' => 'board']); }
/** * Deletes an existing Board model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); $forum_url = $model->forum['forum_url']; if ($model->user_id === Yii::$app->user->id) { Thread::deleteAll(['board_id' => $model->id]); $model->delete(); Yii::$app->getSession()->setFlash('success', 'Delete successfully.'); } else { throw new ForbiddenHttpException('You are not allowed to perform this action.'); } return $this->redirect(['/forum/forum/update', 'id' => $forum_url, 'action' => 'board']); }