mercredi 1 novembre 2017

Laravel collection order similar to DB FIELD

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'
});



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2h3pgrV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire