2 years ago

Best approach to group orders to each invoice

Posted 2 years ago by FutureWeb

Hi Lara Folks,

I have two tables:

id, product_id, user_id, price

id, order_id, total, payment_status

I want to list all orders per user but group them by invoice so:

user1 orders product 1,2,3 and 4 pays invoice number 1 and then orders product 5,6,7 and 8 and pays invoice 2

I would like to display this as:

Invoice 1: Product xx - £20 Product xxx - £10

Invoice 2: Product yy - £30

you get the idea the long and the short of it is I need to access the invoices through the orders table but group by invoice

is there a nice simple way using Eloquent relationships rather than writing a join

Please sign in or create an account to participate in this conversation.