dimanche 18 avril 2021

Laravel 5.2 - Can You Create A Relationship Between A Pivot Table And A Table It's Not Pivoting For?

I have a pivot table called user_store. It's used to establish a many to many relationship between the users table and the stores table and looks something like this:

user_id - int
store_id - int
user_age_range - string

I have another table called user_memberships. It's columns look like:

user_id - int
store_id - int
membership_cost - decimal
membership_expiration - date

I need to establish a relationship between the user_memberships table and the user_store pivot table using the user_id and store_id columns present in both tables.

How would I do this when the user_store table does not have its own model (since it's a pivot table)?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dv72tA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire