Laravel 10 Get Random Records from Database Tutorial
You can use the inRandomOrder() method to get random records in Laravel. This method is available in Laravel 5.2 and later.
*Here are some examples of how to use inRandomOrder():
*
Post::select('id', 'title', 'slug')->inRandomOrder()->get()
$randomComment = Comment::query() ->inRandomOrder() ->first()
Read More Laravel 10 Get Random Records from Database Tutorial
Top comments (0)