fix amount 8

This commit is contained in:
2026-06-09 16:44:02 +03:30
parent 918e8b4f76
commit 9f4f0c0145
7 changed files with 317 additions and 2 deletions
+24
View File
@@ -18,6 +18,7 @@ class Product extends Model
private static ?bool $priceOffsetColumnExists = null;
private static ?bool $priceColumnExists = null;
private static ?bool $orderLimitColumnsExist = null;
private static ?bool $showInAssetsColumnExists = null;
protected static function booted(): void
{
@@ -32,6 +33,9 @@ class Product extends Model
$product->attributes['max_order_cash']
);
}
if (!static::hasShowInAssetsColumn()) {
unset($product->attributes['show_in_assets']);
}
});
}
@@ -87,6 +91,24 @@ class Product extends Model
return static::$orderLimitColumnsExist;
}
public static function hasShowInAssetsColumn(): bool
{
if (static::$showInAssetsColumnExists !== null) {
return static::$showInAssetsColumnExists;
}
try {
static::$showInAssetsColumnExists = Schema::hasColumn(
(new static)->getTable(),
'show_in_assets'
);
} catch (\Throwable) {
static::$showInAssetsColumnExists = false;
}
return static::$showInAssetsColumnExists;
}
public function orderLimitsEnabled(): bool
{
if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {
@@ -137,6 +159,7 @@ class Product extends Model
'active', // The active status of the record (boolean).
'for_barayand', // Whether it is for Barayand (boolean).
'show', // Whether to show the record (boolean).
'show_in_assets', // Show balance on customer assets page cards
'open_sell', // Whether selling is open (boolean).
'auto_open_at', // Whether selling is open (boolean).
'auto_close_at', // Whether selling is open (boolean).
@@ -161,6 +184,7 @@ class Product extends Model
'can_canceled' => 'boolean', // Cast to boolean.
'active' => 'boolean', // Cast to boolean.
'show' => 'boolean', // Cast to boolean.
'show_in_assets' => 'boolean',
'for_barayand' => 'boolean', // Cast to boolean.
'open_sell' => 'boolean', // Cast to boolean.
'auto_sell' => 'boolean', // Cast to boolean (you mentioned this in your casts but it's missing in `$fillable`).