etehadie removed
This commit is contained in:
+32
-1
@@ -6,19 +6,50 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Rooyesh\Wallet\models\Transaction;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory,Selector;
|
||||
|
||||
private static ?bool $typeColumnExists = null;
|
||||
|
||||
public static function hasTypeColumn(): bool
|
||||
{
|
||||
if (static::$typeColumnExists !== null) {
|
||||
return static::$typeColumnExists;
|
||||
}
|
||||
|
||||
try {
|
||||
static::$typeColumnExists = Schema::hasColumn((new static)->getTable(), 'type');
|
||||
} catch (\Throwable) {
|
||||
static::$typeColumnExists = false;
|
||||
}
|
||||
|
||||
return static::$typeColumnExists;
|
||||
}
|
||||
|
||||
/** @return array<int, string> */
|
||||
public static function adminSelectColumns(): array
|
||||
{
|
||||
$cols = ['id', 'title_fa', 'key', 'value', 'description', 'is_active'];
|
||||
if (static::hasTypeColumn()) {
|
||||
$cols[] = 'type';
|
||||
}
|
||||
|
||||
return $cols;
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'title_fa',
|
||||
'is_active',
|
||||
'description',
|
||||
'value',
|
||||
'value_json'
|
||||
'value_json',
|
||||
'type',
|
||||
];
|
||||
protected $casts = [
|
||||
'value_json'=>'array',
|
||||
|
||||
Reference in New Issue
Block a user