mardi 22 mars 2016

How to order and sort my records from eloquent

Hi I have a query which fetches all the category names and displays them in the frontend. now the problem is that category names have a field name called others ( it could be like other fruits or other vegetables etc). Now The others record names I want them to come in the last of the collection I get.

The query

$subcat = Category::where('parent_category_id', 62)->where('is_active', 1)->lists('name', 'id');

What It is gonna return is

Illuminate\Support\Collection Object
    (
        [items:protected] => Array
        (
            [64] => Grapes
            [65] => Pineapple
            [66] => Cranberry
            [67] => Strawberry
            [68] => Pomogranate 
            [69] => Others //like this
            [71] => Orange & Apple
            [72] => Guava & Mango
            [73] => Mixed Fruit
            [384] => Other Juices //another one
            [395] => Concentrates
        )

    )

I want to place the other field names at the last.

Please assist me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire