Pre-populating form and saving to pivot
4 tables and one pivot table:
Products
, Product_Options
, Product_Option_Values
, and Product_Variants
. The pivot table essentially just joins the 3 latter tables with unique constraints. I've made a custom pivot model for this and the relationship for the variant is selectedOptions
which you'll see below.
The user creates a product, then creates its "Product Options" with available "Values". For example, Size: SM, MD, LG
and Color: Red, Blue
This works fine. The issue I'm encountering is when the user goes to create a new Product Variant (via a relation manage on the Product), I want to loop through all available Product Options and have them select a Value.
I've tried a number of things but none of it seems to be working correctly. This is the gist of one route I went:1 Reply
My example is a bit messy but I'm throwing things at the wall here to see what sticks. Hoping somebody can help point me in the right direction.