dimanche 19 mai 2019

Remove unwanted array from json

I'm new to Laravel. I'm creating a json structure using a function. This is my current output:

{
    "success": "1",
    "data": [
        {
            "category_type_id": 1,
            "category_type": "Study",
            "category_icon": "http://192.168.1.132:8000/images/category/study.svg"
        },
        {
            "category_type_id": 2,
            "category_type": "Sports",
            "category_icon": "http://192.168.1.132:8000/images/category/game.svg"
        },
        {
            "category_type_id": 3,
            "category_type": "Other",
            "category_icon": "http://192.168.1.132:8000/images/category/other.svg"
        }
    ]
}

This is my controller code:

$get_all_category = CategoryType::all();

return response()->json(['success' => '1', 'data' => $get_all_category]);

I want result without array that is started from data plz need solution



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire