Пример #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;
 }
Пример #2
0
 /**
  * 添加评论
  * @param Comment $comment
  * @return bool
  */
 public function addComment(Comment $comment)
 {
     $comment->tid = $this->id;
     $comment->fid = $this->fid;
     $result = $comment->save();
     if ($result) {
         $this->updateAttributes(['comment_count' => $this->comment_count + 1]);
         return true;
     }
     return false;
 }