zarbox added 2

This commit is contained in:
2026-06-04 14:42:22 +03:30
parent 92d01f96da
commit f5d53b2747
4 changed files with 86 additions and 9 deletions
+17
View File
@@ -16,6 +16,7 @@ class Product extends Model
use HasFactory,Selector,SoftDeletes;
private static ?bool $priceOffsetColumnExists = null;
private static ?bool $priceColumnExists = null;
protected static function booted(): void
{
@@ -44,6 +45,22 @@ class Product extends Model
return static::$priceOffsetColumnExists;
}
/** گلد علی: جدول products ممکن است ستون price نداشته باشد */
public static function hasStoredPriceColumns(): bool
{
if (static::$priceColumnExists !== null) {
return static::$priceColumnExists;
}
try {
static::$priceColumnExists = Schema::hasColumn((new static)->getTable(), 'price');
} catch (\Throwable) {
static::$priceColumnExists = false;
}
return static::$priceColumnExists;
}
public function getPriceOffsetPercentAttribute($value): float
{
if (!static::hasPriceOffsetColumn()) {