Relationship between Many to Many Laravel

Asked

Viewed 24 times

1

Good evening, let’s say I have the following models: Donor, Donation, Institution

i need to create a relationship between the donations and the Institutions INTERESTED in the donation, N institutions may be interested in 1 or N donations. Then display to the donor to decide which institution will get the donation.

Should I create a pivot table? my doubt is this, if I also have to create a model to accomplish that relationship... I’m in trouble.. How would you solve this problem? Thank you.

  • Kassio, could improve the description, got a little confused. For example, the institution and donation table has a kind of relationship?

  • Thank you for your reply André, sorry for the lack of information; No! but in business rules, donors make donations, institutions can request them, and the donor chooses who they go to!

  • I understood that the institution will create various forms of donation and that the donor will there choose the one that interests him the most, so a donation can be related to multiple donors as a donor to multiple donations. Thus the relationship between donor and donation would in fact have to be a Many to Many, as the normalization rules indicate, it is necessary to create a table to represent this relationship, placing the unique identifiers of each table.

  • But you do not need to create a model to define the relationship N M or N N, but rather define in the models Institutions and donate that the relationship between them are N M (many to many)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.