I built many to many connections.In the intermediate table I keep id-order and id-goods.But where to store attributes.The first thing that occurred to me was here, in the intermediate table.The only problem is that through this pivot, I can only access order_id and product_id.How to reach other fields with type attributes color etc?

Or my approach is fundamentally wrong and attributes need a separate table(then it will complicate things, I don’t know how to organize it)?

I would be grateful for the help.

1 Answers 1

withPivotadd any fields to the relationship
return relations->withPivot('color','column2');
If there are a lot of attributes, you can do some OrderDetail and link it to orders.