Пример #1
0
 /**
  * Displays a single Thread model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $newPost = new Post();
     if ($newPost->load(Yii::$app->request->post())) {
         $newPost->thread_id = $model->id;
         if ($newPost->save()) {
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Create successfully.'));
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('view', ['model' => $model, 'newPost' => $newPost]);
 }
Пример #2
0
 /**
  * Displays a single Thread model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $newPost = new Post();
     if ($newPost->load(Yii::$app->request->post())) {
         $newPost->thread_id = $model->id;
         if ($newPost->save()) {
             if ($model->user_id !== Yii::$app->user->id) {
                 Yii::$app->userData->updateKey('unread_comment_count', $model->user_id);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('view', ['model' => $model, 'newPost' => $newPost]);
 }