示例#1
0
 /**
  * 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);
     if ($model->user_id === Yii::$app->user->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']);
     } else {
         throw new ForbiddenHttpException('You are not allowed to perform this action.');
     }
 }