From 6ebd02beb853b0c1322ddf9a028198847a1c18e4 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 22 Jun 2026 20:09:56 +0330 Subject: [PATCH] fixed show true when price is 0 4 --- .../Controllers/Admin/ProductController.php | 4 ++++ app/Models/Product.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 42d90b6..5526f4c 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -612,6 +612,10 @@ class ProductController extends SuperController unset($data['direct_price']); } + if (!Product::hasInventoryColumn()) { + unset($data['inventory']); + } + return $data; } } diff --git a/app/Models/Product.php b/app/Models/Product.php index 135c751..56ce3a9 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -22,6 +22,7 @@ class Product extends Model private static ?bool $useLastPriceIfZeroColumnExists = null; private static ?bool $directPriceColumnExists = null; private static ?bool $tradeByQuantityColumnExists = null; + private static ?bool $inventoryColumnExists = null; protected static function booted(): void { @@ -48,6 +49,9 @@ class Product extends Model if (!static::hasTradeByQuantityColumn()) { unset($product->attributes['trade_by_quantity']); } + if (!static::hasInventoryColumn()) { + unset($product->attributes['inventory']); + } }); } @@ -175,6 +179,24 @@ class Product extends Model return static::$tradeByQuantityColumnExists; } + public static function hasInventoryColumn(): bool + { + if (static::$inventoryColumnExists !== null) { + return static::$inventoryColumnExists; + } + + try { + static::$inventoryColumnExists = Schema::hasColumn( + (new static)->getTable(), + 'inventory' + ); + } catch (\Throwable) { + static::$inventoryColumnExists = false; + } + + return static::$inventoryColumnExists; + } + public function orderLimitsEnabled(): bool { if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {