Flarum\Core\Discussion::refreshCommentsCount PHP Méthode

refreshCommentsCount() public méthode

Refresh the discussion's comments count.
    public function refreshCommentsCount()
    {
        $this->comments_count = $this->comments()->count();
        return $this;
    }

Usage Example

 /**
  * Refreshes count and last Post for the discussion.
  *
  * @param Discussion $discussion
  */
 protected function refreshDiscussion(Discussion $discussion)
 {
     $discussion->refreshLastPost();
     $discussion->refreshCommentsCount();
     $discussion->refreshParticipantsCount();
     // Persist the new statistics.
     $discussion->save();
     return Discussion::find($discussion->id);
 }