zarbox added 2
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user