jeudi 1 octobre 2015

Laravel Remove [data] from collection

I've tried to query using eloquent and fractal

 $lists = Category::all();

 $result = Fractal::collection($lists, new CategoryTransformer())->getArray();

and return it

 return response()->json((['code' => "200", 'results' => $result]));

the json result is this:

{"code":"200","results":{"data":[{"id":"1","name":"Cafe","logo":null,"cover":""},{"id":"2","name":"SPA","logo":null,"cover":""},{"id":"3","name":"Hotel","logo":null,"cover":""}]}}

How to remove "data" after result?. So i can just get the array without "data".

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire