/**
  * Creates a new TopicContent model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new TopicContent();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function append()
 {
     if ($this->validate()) {
         $this->updated_at = time();
         if ($this->save()) {
             $topicContent = new TopicContent();
             if ($topicContent->load(Yii::$app->request->post())) {
                 $search = Search::findOne($this->id);
                 if (!empty($search)) {
                     $search->content .= $topicContent->content;
                     $search->save();
                 }
                 $topicContent->topic_id = $this->id;
                 $topicContent->is_append = 1;
                 $topicContent->created = time();
                 return $topicContent->save();
             }
         }
     }
     return false;
 }