I have a query with following order
$query->orderByRaw("FIELD(type, 'red', 'green', 'aqua') ASC");
This will order items not alphabetically, but specifically by the value.
Is there is a way to do same thing in Laravel
collection?
Like:
$collection = collect(`Items from DB`);
$final = $collection->orderBy(function($item){
return $item->color == 'red'
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire