fix price force refresh
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user