how to shuffle data in laravel?
ReportQuestion
2 years ago 718 views
You can shuffle data through collection or direct Eloquent
laravel collection shuffle
$collection = collect([1, 2, 3, 4, 5]);
$shuffled = $collection->shuffle();
$shuffled->all();
eloquent shuffle
User::all()->random();
User::all()->random(10);
Thread Reply