Using Query Builder
$randomUser = DB::table('users') ->inRandomOrder() ->first();
Using Eloquent Model
$randomComment = Comment::query() ->inRandomOrder() ->first();
Both of the queries above will return a random record.
2.1K
3 years ago
0 comments
$randomUser = DB::table('users') ->inRandomOrder() ->first();
$randomComment = Comment::query() ->inRandomOrder() ->first();
Frontend
Resource
Average
Average
No recent searches
Leave a reply