示例#1
0
 /**
  * 添加评论
  * @param Comment $comment
  * @param bool $active 激活
  * @return bool
  */
 public function addComment(Comment $comment, $active = false)
 {
     $comment->setAttributes(['tid' => $this->id, 'fid' => $this->fid]);
     $result = $comment->save();
     if ($result) {
         $active && $comment->setActive();
         return true;
     }
     return false;
 }
 public function commentInit()
 {
     if (!$this->topic) {
         return;
     }
     Console::output('创建默认评论 ....');
     $comment = new Comment();
     $comment->setAttributes(['author_id' => 1, 'content' => '默认评论内容']);
     $message = $this->topic->addComment($comment, true) ? '成功' : '失败';
     Console::output('创建默认评论' . $message);
 }
 public function commentInit()
 {
     if (!$this->topic) {
         return;
     }
     echo PHP_EOL . '创建默认评论 ....' . PHP_EOL;
     $comment = new Comment();
     $comment->setAttributes(['author_id' => 1, 'content' => '默认评论内容']);
     $message = $this->topic->addComment($comment) ? '成功' : '失败';
     echo PHP_EOL . '创建默认评论' . $message . PHP_EOL;
 }