Sep 8, 2020
0
Level 1
Eloquent sum relationship and group by
Hello, I have 3 tables:
financials: id, group_id, year
groups: id, name
earnings: id, amount, financial_id
I need to build a query in order to sum group earnings by year. The desired response will be like:
{
[2019]: [
{
name: group name,
total_earnings: total earnings amount
},
...
],
[2020]: [
....
]
}
Please or to participate in this conversation.