diff --git "a/resources/views/components/users/\342\232\241info-cards.blade.php" "b/resources/views/components/users/\342\232\241info-cards.blade.php" index da2b8a54..27a21fe8 100644 --- "a/resources/views/components/users/\342\232\241info-cards.blade.php" +++ "b/resources/views/components/users/\342\232\241info-cards.blade.php" @@ -14,6 +14,7 @@ public function render() { $user = User::find($this->userId)->loadCount([ + 'posts', 'posts as posts_count_in_this_year' => function ($query) { $query->whereYear('created_at', date('Y')); }, @@ -24,11 +25,12 @@ public function render() ->where('posts.user_id', $user->id) ->count(); - $categories = Category::with([ - 'posts' => function ($query) use ($user) { - $query->where('user_id', $user->id); - }, - ])->get(); + $categories = Category::query() + ->withCount([ + 'posts' => function ($query) use ($user) { + $query->where('user_id', $user->id); + }, + ])->get(); return $this->view([ 'user' => $user, @@ -129,8 +131,8 @@ class="rounded-full size-36"