mercredi 25 mai 2016

When should pivot table models in Laravel be used?

I'm having a tough time wrapping my head around a problem that I believe requires me to turn a pivot table into a model. Assume there are two tables:

  • Group (which has a pivot table group_members, which takes into account different types of users, etc)
  • Notifications

Now, the relationship I wanted to model was between Notifications and group_members, as many group_members can be the recipient of a notification, and a many different notifications can be sent out to a particular group_member. This seems to require another pivot table: notification_group_members.

So, really, what it seems to be is that I have a relationship between two pivot tables. I'm not sure if this is a modeling issue, as it seems to be a little odd to create models of pivot tables. The documentation says that generally you wouldn't be doing that. Is this one of the cases where it would make sense to?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1sbd1co
via IFTTT

Aucun commentaire:

Enregistrer un commentaire