The following:
Customer::with('tickets:customer_id,subject')->get();
returns the following:
[
{
"id": 1,
"company": "Test Ltd",
"support": "Standard",
"tickets": [
{
"customer_id": "1",
"name": "Test ticket 1"
},
{
"customer_id": "1",
"name": "Test ticket 2"
}
]
}
]
How can I flatten the related field, tickets to get tickets: ["Test ticket 1", "Test ticket 2"]? I tried doing a ->flatten() after ->get() but that didn't work at all. It feels like it should be something simple that I'm missing and just can't find in the docs or by googling (thanks for the word with, that screws pretty much all sane results...)
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EXA2YE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire