diff --git a/app/Livewire/Posts/PostIndexItemComponent.php b/app/Livewire/Posts/PostIndexItemComponent.php
index e8a6c2f3..4529ca41 100644
--- a/app/Livewire/Posts/PostIndexItemComponent.php
+++ b/app/Livewire/Posts/PostIndexItemComponent.php
@@ -21,7 +21,7 @@ public function mount(Post $post): void
{
$this->authorizedUserId = $this->getAuthorizedUserId();
$this->post = $post;
- $this->commentCount = $post->comments()->count();
+ $this->commentCount = $post->commentsCount();
}
public function render(): View
diff --git a/app/Models/Post.php b/app/Models/Post.php
index 2f76bf97..913fd6fd 100644
--- a/app/Models/Post.php
+++ b/app/Models/Post.php
@@ -143,6 +143,12 @@ public function comments(): HasMany
return $this->hasMany(Comment::class);
}
+ public function commentsCount(): int
+ {
+ // Only count comments by regular users, not moderator actions
+ return $this->hasMany(Comment::class)->whereNull('moderation_type')->count();
+ }
+
public function bookmarkCount(): int
{
return Bookmark::count($this);
diff --git a/resources/views/posts/partials/post-index-footer.blade.php b/resources/views/posts/partials/post-index-footer.blade.php
index d9d9985a..7a3da17f 100644
--- a/resources/views/posts/partials/post-index-footer.blade.php
+++ b/resources/views/posts/partials/post-index-footer.blade.php
@@ -9,6 +9,6 @@
href="{{ $post->present()->url }}#comments"
title="{{ trans('Comments') }}">
- {{ $post->comments()->count() > 0 ?: 0 }}
+ {{ $post->commentsCount() }}
diff --git a/resources/views/posts/partials/post-show-footer.blade.php b/resources/views/posts/partials/post-show-footer.blade.php
index b3e86a60..3cd72baf 100644
--- a/resources/views/posts/partials/post-show-footer.blade.php
+++ b/resources/views/posts/partials/post-show-footer.blade.php
@@ -15,7 +15,7 @@
- {{ $commentsCount > 0 ?: 0 }}
+ {{ $commentsCount }}
@if (isset($favoritesCount) && $favoritesCount > 0)
diff --git a/resources/views/posts/show.blade.php b/resources/views/posts/show.blade.php
index 789a41d8..25b2dbbe 100644
--- a/resources/views/posts/show.blade.php
+++ b/resources/views/posts/show.blade.php
@@ -42,7 +42,7 @@
@include('posts.partials.post-show-footer', [
'post' => $post,
- 'commentsCount' => $post->comments()->count(),
+ 'commentsCount' => $post->commentsCount(),
'favoritesCount' => $post->favoriteCount(),
])