WIP
This commit is contained in:
@@ -106,6 +106,23 @@ class FilterController extends Controller
|
||||
->get();
|
||||
}
|
||||
|
||||
if ($this->shouldFilterByChannel()) {
|
||||
$channelId = (int) $this->request->channel_id;
|
||||
|
||||
return DB::table('brands')
|
||||
->select('brands.id', 'brands.name')
|
||||
->join('products', 'products.brand_id', '=', 'brands.id')
|
||||
->join('product_has_relations', 'products.id', '=', 'product_has_relations.product_id')
|
||||
->where('product_has_relations.productable_type', 'channel')
|
||||
->where('product_has_relations.productable_id', $channelId)
|
||||
->where('products.is_visible', true)
|
||||
->whereNull('products.parent_id')
|
||||
->where('products.stock', '>', 0)
|
||||
->groupBy('brands.id', 'brands.name', 'brands.sort_order')
|
||||
->orderBy('brands.sort_order')
|
||||
->get();
|
||||
}
|
||||
|
||||
return Brand::query()->where('is_visible', true)->ordered()->get(['id', 'name']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user