S
S
semki0962019-05-17 11:12:16
Laravel
semki096, 2019-05-17 11:12:16

In which table to store order attributes?

Build a many-to-many relationship. In the intermediate table I store id-заказаand id-товара. But where to store the attributes. The first thing that came to mind is here, in the intermediate table. The only problem is that pivotI can only access this table through order_idand product_id. How to reach the rest of the fields with type attributes, coloretc.?
Or is my approach fundamentally wrong and a separate table is needed for attributes (then it will complicate everything, I don’t know how to organize it)?
I would be grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2019-05-17
@semki096

withPivot will add any fields to the relationship. If there are many attributes, you can make some kind of OrderDetail and associate with orders

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question