The method name is belongsToMany on both sides of the relationship whenever you use a pivot table.
Jun 2, 2020
3
Level 3
Relationship between "Users" and "Products" with pivot "Order" table?
I have 3 tables, users, products and orders, the users and products has a relationship of many-to-many, but, what is the relationship in the methods of the user model? I understand that a product belongs-to-many users but, a user belongs to many products? Is it right? I don't think so.
Or i can do a user hasMany products? Is it will be wrong if i do a user hasMany products in a relationship of many-to-many between users and products? Or the two relations have to be obligatorily a "belongsToMany"?
Please or to participate in this conversation.