Arrays of joined ids
Thanks to a helpful stack overflow response, I now have an improved solution to my problem of needing to add arrays of joined ids to JSON output from CakePHP 3. The output from a test containing Widget models that can each have many Foos looks something like this:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {     "widgets": [         {             "id": 1,             "foo_ids": [ 1 ]         },         {             "id": 3,             "foo_ids": [ ]         },         {             "id": 2,             "foo_ids": [ 1, 2, 3 ]         }     ] } | 
To easily and automatically add this … [Read more…]