Level 23
r u wanting to display brands in side bar?
if so then you need to dobrand::wherehas(prod.catrgories, func() {...})->with()
I'm working on an ecommerce app, and I have the following tables:
products:
id, name, description, category_id, brand_id, sku, created_at... etc
brands:
id, name
categories:
id,name,parent_id
Say I have this, to retrieve products with those categories, how will I also retrieve all brands that products use without having duplicates? Since different brands can have the same brand, so it won't be displayed in the filtering sidebar.
$products = Product::whereIn('category_id', [1, 2, 3])->get();
Please or to participate in this conversation.