I have below setup for tables:
Product_variant
Table
Product_variant -> id, name, code, image
Warehouse
table
Warehouse -> id, name, address
Product Variant Stock
table
Product_Variant_stock -> stock_id, warehouse_id, variant_id, stock_qty
Now, what i need to get information is about in which Warehouse, variant has been stored, when i try to access product variant information.
What i have tried in ProductVariation model:
public function warehouseName()
{
return $this->hasOneThrough(Warehouse::class, ProductVariantStock::class, 'warehouse_id', 'id');
}
Above is not working as expected. Any help is appreciated.