@yediyuz When I model this in e-commerce applications, there are two models: a Product (which holds common details such as name) and then multiple Skus. A Sku model holds a particular variation’s details, including price.
In your case, I’d also have another model: ProductAttribute. This model would hold the name of an attribute (such as “Color”), and then a pivot table between attributes and SKUs that also has a pivot column for the value. This way, for each SKU, you can see its colour, size, etc.
In terms of controllers, SKUs would then become a “nested” resource under products, making your URI structure look similar to this:
-
/products/{products}/skus -
/products/{products}/skus/{sku}
