fixed post count
Some checks failed
CI/CD Pipeline / test (push) Successful in 3s
CI/CD Pipeline / deploy (push) Failing after 1s

This commit is contained in:
Micha
2026-01-18 18:26:51 +01:00
parent 534c38d58a
commit 8e029d2a94
5 changed files with 18 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ class PostController extends Controller
{
$query = Post::query()->withoutTrashed()->with([
'user' => fn ($query) => $query
->withCount(['posts', 'thanksGiven', 'thanksReceived'])
->withCount(['posts', 'threads', 'thanksGiven', 'thanksReceived'])
->with(['rank', 'roles']),
]);
@@ -52,7 +52,7 @@ class PostController extends Controller
$post->loadMissing([
'user' => fn ($query) => $query
->withCount(['posts', 'thanksGiven', 'thanksReceived'])
->withCount(['posts', 'threads', 'thanksGiven', 'thanksReceived'])
->with(['rank', 'roles']),
]);
@@ -96,7 +96,7 @@ class PostController extends Controller
'user_avatar_url' => $post->user?->avatar_path
? Storage::url($post->user->avatar_path)
: null,
'user_posts_count' => $post->user?->posts_count,
'user_posts_count' => ($post->user?->posts_count ?? 0) + ($post->user?->threads_count ?? 0),
'user_created_at' => $post->user?->created_at?->toIso8601String(),
'user_location' => $post->user?->location,
'user_thanks_given_count' => $post->user?->thanks_given_count ?? 0,