How did it get in this shape in the first place? Seems like it would be easier to simply query the database
Oct 9, 2022
4
Level 1
how to get specific column data from multi array collection
I have collection which is:
[
{
"date": "2022-10-09",
"invoices": [
{
"title": "allowance",
"credit": 200,
"debit": null
},
{
"title": "license",
"credit": 100,
"debit": null
},
{
"title": "donation",
"credit": null,
"debit": 4000
},
{
"title": "deposit",
"credit": null,
"debit": 2000
}
],
"balance": "7080.00"
},
{
"date": "2022-10-07",
"invoices": [
{
"title": "license",
"credit": 2000,
"debit": null
}
],
"balance": "1380.00"
},
{
"date": "2022-10-08",
"invoices": [
{
"title": "admission",
"credit": null,
"debit": 1000
}
],
"balance": "3380.00"
}
]
I want to get from here only debit and credit column. Has any direct way to get data like array column from here without loop ? I tried to array_column but its not working here because its a collection and If I do toArray() its not working because its return me data as date.
so I don't understand how to direct get column (credit/debit) from here in this collection.
Please or to participate in this conversation.