Using Laravel Eloquent, how can I take 10 random rows from the top 100 (sorted by date).
For example, I have this:
$comments = Comment::orderBy('created_at', 'DESC')
->take(100)
->inRandomOrder()
->get();
How can I change this so that it takes 10 random rows from the 100 selected? Is there a way to do this such that I don't have to retrieve 100 rows?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire