has one through relation in pivot table to another pivot table
Hello I am working on ecommerce applicatio. I want to display product variations in product details page based on a filter option. for instance I have a laptop with color red and I want to be able to display laptops with same information but blue and green color. I need some help in eloquent please consider following tables and models:
products Product filters Filter filter_options FilterOption product_options ProductOption---->pivot table product_variations ProductVariation---->pivot table
product_options table: id productId filterOptionId
product_variations table: id productId1 productId2 filterOptionId
how to can I access to a FilterOption using filterOptionId in product_variations? is it possible to use hasOneThrough? if yes please explain
I want something like below:
$product=Product:find(1); $variations=$product->variations(); foreach($variations as $v){ echo $v->option->displayText; }
thank you
Please or to participate in this conversation.