mercredi 18 mai 2016

How to return response of array of objects

Here is my Response

data : [{id: 30, tmb_order_id: "TMB030"}, {id: 33, tmb_order_id: "TMB033"}]

Like this pic

enter image description here

But i want my Response like

{
    "data": [
        [
            "30",
            "TMB030"
        ],
        [
            "33",
            "TMB033",
        ],
    ]
}

How can i do this ?

Here is the way how i get it in controller

$data = Order::where('user_id',$id)->where('status',1)->select('id', 'tmb_order_id')->get();
        $Response = array('data' => $data ); 
        return $Response;

What should i do to get the response like that ?

Help pls



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire