Use inRandomOrder instead of orderByRaw in Discover page

This commit is contained in:
Neil Alexander 2018-06-01 12:13:32 +01:00 committed by GitHub
parent 9fbc5d0902
commit 11447c13da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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'));
}