fix price force refresh

This commit is contained in:
2026-06-14 12:01:20 +03:30
parent 50a726f251
commit 1abddfbab8
6 changed files with 229 additions and 37 deletions
+29
View File
@@ -123,4 +123,33 @@ class CategoryService
return $created;
}
/**
* تب‌های فیلتر اپ — فقط دسته‌های فعال که حداقل یک محصول فعال دارند.
* show_in_filter دستی لازم نیست؛ از همان منطق نمایش محصولات مشتق می‌شود.
*/
public function clientFilterCategories(): Collection
{
$groupsWithProducts = Product::query()
->where('active', 1)
->whereNotNull('group_type')
->where('group_type', '!=', '')
->distinct()
->pluck('group_type')
->map(static fn ($name) => trim((string) $name))
->filter()
->unique()
->values();
if ($groupsWithProducts->isEmpty()) {
return collect();
}
return Category::query()
->where('active', 1)
->whereIn('name', $groupsWithProducts)
->orderBy('sort_order')
->orderBy('id')
->get(['id', 'name', 'sort_order']);
}
}