Exemplo n.º 1
0
 public function create()
 {
     $this->created = time();
     $this->user_id = Yii::$app->user->id;
     $this->need_login = Node::findOne($this->node_id)->need_login;
     $this->updated_at = time();
     if ($this->validate()) {
         if ($this->save()) {
             Yii::$app->cache->delete('TopicCount');
             Yii::$app->cache->delete('Ranking');
             Yii::$app->cache->delete('HotNode15');
             $topicContent = new TopicContent();
             if ($topicContent->load(Yii::$app->request->post())) {
                 $search = new Search();
                 $search->topic_id = $this->id;
                 $search->title = $this->title;
                 $search->content = $topicContent->content;
                 $search->save();
                 $topicContent->topic_id = $this->id;
                 $topicContent->created = time();
                 return $topicContent->save();
             }
         }
     }
     return false;
 }