diff --git a/app/Http/Controllers/BrowseController.php b/app/Http/Controllers/BrowseController.php index 3d3f9492a..3186967a8 100644 --- a/app/Http/Controllers/BrowseController.php +++ b/app/Http/Controllers/BrowseController.php @@ -655,21 +655,16 @@ public function getLikesLeaderboard(Request $request) { abort(404); } - $query = Character::with('user.rank')->with('image.features')->with('rarity')->with('image.species')->myo(0)->where(function ($query) { - //only display characters whose users allow likes + $query = Character::myo(0)->where(function ($query) { $query = $query->whereRelation('user.settings', 'allow_character_likes', 1); }); - - $imageQuery = CharacterImage::images(Auth::check() ? Auth::user() : null)->with('features')->with('rarity')->with('species')->with('features'); - $query->whereIn('id', $imageQuery->pluck('character_id')->toArray()); - $randomcharacter = $query->visible()->get()->random(1)->first() ?? null; + $randomcharacter = $query->visible(Auth::user())->get()->random(1)->first() ?? null; if ($request->get('id')) { $query->where(function ($query) use ($request) { $query->where('characters.id', $request->get('id')); }); } - if ($request->get('owner')) { $owner = User::find($request->get('owner')); $query->where(function ($query) use ($owner) { @@ -677,7 +672,7 @@ public function getLikesLeaderboard(Request $request) { }); } - if (!Auth::check() || !Auth::user()->hasPower('manage_characters')) { + if (!Auth::user()->hasPower('manage_characters')) { $query->visible(); }