fix bug ۲

This commit is contained in:
2026-06-15 00:58:15 +03:30
parent 345fbcd929
commit e9ddcacdb6
@@ -181,7 +181,7 @@ class ProductController extends SuperController
if (app(ConfigService::class)->isStore()) { if (app(ConfigService::class)->isStore()) {
app(ProductPriceSyncService::class)->syncStorePrices(true); app(ProductPriceSyncService::class)->syncStorePrices(true);
if (! str_contains(request()->path(), '/customer/')) { if (! $this->isCustomerApiRequest()) {
$this->auto_close_open(); $this->auto_close_open();
} }
@@ -190,7 +190,7 @@ class ProductController extends SuperController
$products = $categoryService->filterProductsByVisibleCategories($products); $products = $categoryService->filterProductsByVisibleCategories($products);
$products = $categoryService->sortProductsForStore($products); $products = $categoryService->sortProductsForStore($products);
if (str_contains(request()->path(), '/customer/')) { if ($this->isCustomerApiRequest()) {
$this->applyCustomerShow($products); $this->applyCustomerShow($products);
} }
@@ -200,11 +200,11 @@ class ProductController extends SuperController
// آبشده خانگی — کران قیمت را آپدیت می‌کند؛ list فقط از DB می‌خواند // آبشده خانگی — کران قیمت را آپدیت می‌کند؛ list فقط از DB می‌خواند
$products = Product::with(['file'])->where('active', 1)->get(); $products = Product::with(['file'])->where('active', 1)->get();
if (str_contains(request()->path(), '/customer/')) { if ($this->isCustomerApiRequest()) {
$this->applyCustomerShow($products); $this->applyCustomerShow($products);
} }
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) { if (Product::hasPriceOffsetColumn() && $this->isCustomerApiRequest()) {
$products->each(function (Product $product) { $products->each(function (Product $product) {
if ($product->reading_method) { if ($product->reading_method) {
$product->makeHidden(['price_offset_percent']); $product->makeHidden(['price_offset_percent']);
@@ -224,7 +224,7 @@ class ProductController extends SuperController
->first(); ->first();
if ($product) { if ($product) {
if (str_contains(request()->path(), '/customer/')) { if ($this->isCustomerApiRequest()) {
$this->applyCustomerShow(collect([$product])); $this->applyCustomerShow(collect([$product]));
} }
@@ -233,7 +233,7 @@ class ProductController extends SuperController
->where('id', '!=', $id) ->where('id', '!=', $id)
->get(); ->get();
if (str_contains(request()->path(), '/customer/')) { if ($this->isCustomerApiRequest()) {
$this->applyCustomerShow($product->similar); $this->applyCustomerShow($product->similar);
} }
} else { } else {
@@ -379,6 +379,11 @@ class ProductController extends SuperController
return false; return false;
} }
private function isCustomerApiRequest(): bool
{
return str_starts_with(request()->path(), 'customer/');
}
private function applyCustomerShow($products): void private function applyCustomerShow($products): void
{ {
$products = $products instanceof \Illuminate\Support\Collection $products = $products instanceof \Illuminate\Support\Collection