File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public function mount(Post $post): void
2121 {
2222 $ this ->authorizedUserId = $ this ->getAuthorizedUserId ();
2323 $ this ->post = $ post ;
24- $ this ->commentCount = $ post ->comments ()-> count ();
24+ $ this ->commentCount = $ post ->commentsCount ();
2525 }
2626
2727 public function render (): View
Original file line number Diff line number Diff line change @@ -143,6 +143,12 @@ public function comments(): HasMany
143143 return $ this ->hasMany (Comment::class);
144144 }
145145
146+ public function commentsCount (): int
147+ {
148+ // Only count comments by regular users, not moderator actions
149+ return $ this ->hasMany (Comment::class)->whereNull ('moderation_type ' )->count ();
150+ }
151+
146152 public function bookmarkCount (): int
147153 {
148154 return Bookmark::count ($ this );
Original file line number Diff line number Diff line change 99 href =" {{ $post -> present ()-> url } } #comments"
1010 title =" {{ trans (' Comments' ) } }" >
1111 <x-icons .icon-component filename =" chat" />
12- {{ $post -> comments () -> count () > 0 ?: 0 } }
12+ {{ $post -> commentsCount () } }
1313 </a >
1414</footer >
Original file line number Diff line number Diff line change 1515
1616 <span >
1717 <x-icons .icon-component filename =" chat" />
18- {{ $commentsCount > 0 ?: 0 } }
18+ {{ $commentsCount } }
1919 </span >
2020
2121 @if (isset ($favoritesCount ) && $favoritesCount > 0 )
Original file line number Diff line number Diff line change 4242
4343 @include (' posts.partials.post-show-footer' , [
4444 ' post' => $post ,
45- ' commentsCount' => $post -> comments () -> count (),
45+ ' commentsCount' => $post -> commentsCount (),
4646 ' favoritesCount' => $post -> favoriteCount (),
4747 ] )
4848 </article >
You can’t perform that action at this time.
0 commit comments