lundi 25 juillet 2016

Laravel Sort Collection By Dynamic ID array

I have the following...

$people = array(5, 2, 9, 6, 11);

$people_collection = People::find($people);

But when I dump and die $people_collection the collection is ordered by the ID ASC, how can I keep the collection, in the same order as the $people array?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire