mardi 31 mai 2016

Laravel - Paginate Random records

How we can paginate through random records in laravel? for example:

$products = Product::all()->orderBy(DB::raw('RAND()'));
$products->paginate(4);
$products->setPath('products');

Above will ends in duplicate records, because of random order. How can I persist the $products object so that, when a new page request made, it should filter though same/fixed random record set ?




Aucun commentaire:

Enregistrer un commentaire