Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AnneGodkona's avatar

how to GROUP BY data in multi relational table

I'm stuck in a omegle.2yu.co problem https://omegle.love that how to GROUP BY data in multi relational table. Here is my code:

$invoices = Invoice::select('id', 'date', 'type') ->with('invoice_items:invoice_id,item_id,amount', 'invoice_items.item_title:id,name') ->latest('id') ->get();

0 likes
2 replies
jlrdw's avatar

It looks more like you want to display an invoice and the line items. That's just related data, not a GROUP BY.

Please or to participate in this conversation.