From e9ddcacdb607c851cff3915883360ac77beb9b52 Mon Sep 17 00:00:00 2001 From: mohammad sedighi Date: Mon, 15 Jun 2026 00:58:15 +0330 Subject: [PATCH] =?UTF-8?q?fix=20bug=20=DB=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/ProductController.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 5677406..6103ab4 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -181,7 +181,7 @@ class ProductController extends SuperController if (app(ConfigService::class)->isStore()) { app(ProductPriceSyncService::class)->syncStorePrices(true); - if (! str_contains(request()->path(), '/customer/')) { + if (! $this->isCustomerApiRequest()) { $this->auto_close_open(); } @@ -190,7 +190,7 @@ class ProductController extends SuperController $products = $categoryService->filterProductsByVisibleCategories($products); $products = $categoryService->sortProductsForStore($products); - if (str_contains(request()->path(), '/customer/')) { + if ($this->isCustomerApiRequest()) { $this->applyCustomerShow($products); } @@ -200,11 +200,11 @@ class ProductController extends SuperController // آبشده خانگی — کران قیمت را آپدیت می‌کند؛ list فقط از DB می‌خواند $products = Product::with(['file'])->where('active', 1)->get(); - if (str_contains(request()->path(), '/customer/')) { + if ($this->isCustomerApiRequest()) { $this->applyCustomerShow($products); } - if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) { + if (Product::hasPriceOffsetColumn() && $this->isCustomerApiRequest()) { $products->each(function (Product $product) { if ($product->reading_method) { $product->makeHidden(['price_offset_percent']); @@ -224,7 +224,7 @@ class ProductController extends SuperController ->first(); if ($product) { - if (str_contains(request()->path(), '/customer/')) { + if ($this->isCustomerApiRequest()) { $this->applyCustomerShow(collect([$product])); } @@ -233,7 +233,7 @@ class ProductController extends SuperController ->where('id', '!=', $id) ->get(); - if (str_contains(request()->path(), '/customer/')) { + if ($this->isCustomerApiRequest()) { $this->applyCustomerShow($product->similar); } } else { @@ -379,6 +379,11 @@ class ProductController extends SuperController return false; } + private function isCustomerApiRequest(): bool + { + return str_starts_with(request()->path(), 'customer/'); + } + private function applyCustomerShow($products): void { $products = $products instanceof \Illuminate\Support\Collection