This commit is contained in:
Mekan1206
2026-05-04 16:47:49 +05:00
parent 859e4ebbe8
commit 715acc4e97

View File

@@ -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']);
}