From 324efdbb293a53c0c8580dbc6887ded10acf2bae Mon Sep 17 00:00:00 2001 From: Punyapal Shah Date: Mon, 15 Apr 2024 22:19:29 +0530 Subject: [PATCH] Refactor Users.php to load links when shuffling and remove egger loading 2 times --- app/Livewire/Home/Users.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Home/Users.php b/app/Livewire/Home/Users.php index bc92ceee4..d21e148e0 100644 --- a/app/Livewire/Home/Users.php +++ b/app/Livewire/Home/Users.php @@ -65,7 +65,8 @@ private function defaultUsers(): Collection return $this->famousUsers($verifiedUsers) ->merge($verifiedUsers) - ->shuffle(); + ->shuffle() + ->load('links'); } /** @@ -90,7 +91,6 @@ private function famousUsers(Collection $except): Collection return User::query() ->fromSub($famousUsers, 'top_users') - ->with('links') ->inRandomOrder() ->limit(10 - $except->count()) ->get(); @@ -108,7 +108,6 @@ private function verifiedUsers(int $limit = 2): Collection $query->where('url', 'like', '%twitter.com%') ->orWhere('url', 'like', '%github.com%'); }) - ->with('links') ->where(function (Builder $query): void { $query->where('is_verified', true) ->orWhereIn('username', array_merge(