
laravel eloquent inRandomOrder query example
In this article, We will explain to you how to get random row data in laravel(laravel eloquent inRandomOrder query example).
The laravel eloquent provides many types of eloquent methods. so we can easily get random row data into the database using the in random order eloquent method.
There are two ways to get random data into the database. so you can see below the following example.
1 2 3 4 5 6 7 8 9 10 | //first way $students = DB::table('students') ->inRandomOrder() ->get(); //second way $students = DB::table('students') ->orderByRaw("RAND()") ->get(); |
Please follow and like us: