Maybe my example here will help, or at least get you started:
https://laracasts.com/discuss/channels/eloquent/creating-a-belongs-to-many-relationship
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables that need to join together with manyToMany relationship. I understand how to join 2 tables with a pivot table. For this case, I need to relate id from 3 tables in a pivot table.
Can you tell me how to setup the eloquent relationships? Is there any example?
Below is the example of the database setup.
Product
Attribute
Attribute_value
attribute_product_value_pivot
Please or to participate in this conversation.