lundi 31 octobre 2016

Laravel / Eloquent - Multiple Many to Many Relationships Using One Reference Table

I have a table that looks lie:

enter image description here

The table serves as a reference table between two tables. The kicker is that the second table this reference table serves depends on the value of member_type.

There are three tables being connected using the above table: incidents, user_member_incidents, and server_member_incidents. The member_id column in the reference table references either the user_member_incidents table or the server_member_incidents table. This is determined by the value of the member_type column.

How would I reflect this relationship using a belongsToMany method in Eloquent?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire