From 715acc4e97e7ea82ad986c0f522fc914a1d5f2a4 Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Mon, 4 May 2026 16:47:49 +0500 Subject: [PATCH] WIP --- .../Api/V1/Filters/FilterController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Http/Controllers/Api/V1/Filters/FilterController.php b/app/Http/Controllers/Api/V1/Filters/FilterController.php index b70a160..dd7e1f0 100644 --- a/app/Http/Controllers/Api/V1/Filters/FilterController.php +++ b/app/Http/Controllers/Api/V1/Filters/FilterController.php @@ -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']); }