Do you guys have any suggestions on how to random an object coming from the database? Example: I have an item table, inside the item table, I have (3) items. Then I requested an item which matches to the (3)items, and I only need to match (1)item out of those (3), using a random function..
Asked
Active
Viewed 53 times
0
-
4Possible duplicate of [Laravel - Eloquent or Fluent random row](https://stackoverflow.com/questions/13917558/laravel-eloquent-or-fluent-random-row) – Devon Bessemer Nov 11 '17 at 15:29
-
`$randomUser = DB::table('users')->where('whatever', $whatever)->inRandomOrder()->first();` It looks like a duplicate. – whoacowboy Nov 11 '17 at 15:44
1 Answers
0
$randomItem = Item::where('something, $something)->inRandomOrder()->first();

Omar Tarek
- 734
- 1
- 7
- 19