From 859e4ebbe80fcc53bfc3cd4509295861e65550f3 Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Mon, 4 May 2026 16:44:41 +0500 Subject: [PATCH] tr in category --- .../Controllers/Api/V1/Filters/FilterController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/V1/Filters/FilterController.php b/app/Http/Controllers/Api/V1/Filters/FilterController.php index dba6dd6..b70a160 100644 --- a/app/Http/Controllers/Api/V1/Filters/FilterController.php +++ b/app/Http/Controllers/Api/V1/Filters/FilterController.php @@ -38,7 +38,17 @@ class FilterController extends Controller private function categories() { if ($this->shouldFilterByCategory()) { - return Category::find($this->request->category_id, ['id', 'parent_id'])->children()->get(['id', 'parent_id', 'name']); + return Category::query() + ->find($this->request->category_id, ['id', 'parent_id']) + ->children() + ->where('is_visible', true) + ->ordered() + ->get(['id', 'parent_id', 'name']) + ->map(fn ($category) => [ + 'id' => $category->id, + 'parent_id' => $category->parent_id, + 'name' => $category->name, + ]); } if ($this->shouldFilterByCollection()) {