mardi 4 juillet 2017

Add extra key in laravel eloquent result

I have a laravel query builder result that looks like this

 "data": [
        {
            "id": "",
            "awardID": 2,
            "title": "Dummy title",
            "status": "active",
            "raceStart":"",
            "raceEnd:":""
        }
    ]
  

What i want to output is something like this

 "data": [
        {
            "id": "",
            "awardID": 2,
            "title": "Dummy title",
            "status": "active",
            "period": {
              "raceStart":"",
              "raceEnd:":""
            }
        }
    ]
  

This would have been much easier if the period was a table with a 1 to 1 relationship with parent table but this is not the case here. How can this be archived



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sJfATf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire