From 11447c13da7f5fcfef40b1db200c46e359ac9a64 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 Jun 2018 12:13:32 +0100 Subject: [PATCH 1/2] Use inRandomOrder instead of orderByRaw in Discover page --- app/Http/Controllers/DiscoverController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index a8459b370..d7c70e30a 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -16,7 +16,7 @@ class DiscoverController extends Controller public function home() { $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id'); - $people = Profile::whereNotIn('id', $following)->orderByRaw('rand()')->take(3)->get(); + $people = Profile::inRandomOrder()->whereNotIn('id', $following)->take(3)->get(); $posts = Status::whereHas('media')->whereNotIn('profile_id', $following)->orderBy('created_at', 'desc')->take('21')->get(); return view('discover.home', compact('people', 'posts')); } From efbb1017e7fce0cc0271776ea897db75f90ce03a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 Jun 2018 12:23:52 +0100 Subject: [PATCH 2/2] Also fix orderByRaw in SeedFollows --- app/Console/Commands/SeedFollows.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/SeedFollows.php b/app/Console/Commands/SeedFollows.php index 81f23fabb..d11685648 100644 --- a/app/Console/Commands/SeedFollows.php +++ b/app/Console/Commands/SeedFollows.php @@ -41,10 +41,10 @@ class SeedFollows extends Command { $limit = 10000; - for ($i=0; $i < $limit; $i++) { + for ($i=0; $i < $limit; $i++) { try { - $actor = Profile::orderByRaw('rand()')->firstOrFail(); - $target = Profile::orderByRaw('rand()')->firstOrFail(); + $actor = Profile::inRandomOrder()->firstOrFail(); + $target = Profile::inRandomOrder()->firstOrFail(); $follow = new Follower; $follow->profile_id = $actor->id;