Пример #1
0
 /**
  * Deletes an existing Thread 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);
     $board_id = $model->board_id;
     if ($model->user_id === Yii::$app->user->id || $model->board['user_id']) {
         Post::deleteAll(['thread_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/board/view', 'id' => $board_id]);
 }
Пример #2
0
 /**
  * Deletes an existing Thread 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);
     $board_id = $model->board_id;
     Post::deleteAll(['thread_id' => $model->id]);
     $model->delete();
     Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Deleted successfully.'));
     return $this->redirect(['/forum/board/view', 'id' => $board_id]);
 }