mercredi 14 octobre 2020

in laravel add array in single query

i am new in laravel i am trying to get answer like. this is array i want to display on api. how can i merge it.

{
  "data": {
    "ted_talks": [
           "0" : [
                data
            ],
            "1" : [
                data2
            ]
    ],
    "videos": [
         "0" : [
                data3
            ],
            "1" : [
                data4
            ]
    ],
    "music": [
            "0" : [
                data6
            ],
            "1" : [
                data5
            ]
    ],
    .
    .
    .
  }
}

where i have code like this

        $videos = ResourcesVideo::where('resource_type', 'video')->get();

        $videos = ResourcesVideo::where('resource_type', 'music')->get();

        $videos = ResourcesVideo::where('resource_type', 'mediation')->get();

        $videos = TedTalk::get();

i dont understand how can i merge it. with like above array.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire