MarlonV's avatar

Guidance

Hey guys,

I'am stuck with my app setup. I'am building a app for a non-profit organisation. In a nutshell: Users add their kids, and kids can go to a event.

My table setup is as following: User has many kids, and kids have a many tot many relation relation with events.

I manage to sum the total for each.

{{ $child->events()->sum('price') }}

How do i sum the total of the kids?

Then i need to store the price in a sort of payment table what is owned by the user. No clue what kind of relation i need to build here.

Do i need to add the user_id to the child_event table and use the child_event id for my payment relation?

Any thoughts here?

thanks in advance.

0 likes
1 reply
jlrdw's avatar
jlrdw
Best Answer
Level 75

See this, it is a rough draft, wasn't finished at the time, was showing a popup edit:

https://drive.google.com/file/d/0B1_PFw--3o74TC16eXRBYXZBNFk/view

So there I am working with an invoice. It happens to be for spays and neuters, So whether an event, a service, whatever, look at it like a master detail. In my case I went by invoice number, where of course the customer id is on the parent invoice. (In work here, wasn't final), all fields not shown in parent.

It's the invoice id that relates the parent and child, you do not need a customer on the "line items".

https://i.imgur.com/7l7DaPM.jpg

  • Parent = the invoice
  • child = the spays or neuters in this case

Image, top is parent, under is children (line items).

This was also for a non profit. And don't over think this stuff, keep it simple.

Please or to participate in this conversation.