2026-01-24 14:03:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2026-02-09 14:09:19 +03:30
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
2026-06-04 14:19:54 +03:30
|
|
|
use Illuminate\Support\Facades\Schema;
|
2026-02-09 14:09:19 +03:30
|
|
|
use Rooyesh\Wallet\models\Transaction;
|
|
|
|
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
2026-01-24 14:03:11 +00:00
|
|
|
|
|
|
|
|
class Setting extends Model
|
|
|
|
|
{
|
2026-02-09 14:09:19 +03:30
|
|
|
use HasFactory,Selector;
|
2026-06-04 14:19:54 +03:30
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2026-06-04 16:01:13 +03:30
|
|
|
$cols = ['id', 'title_fa', 'key', 'value', 'description', 'is_active', 'can_edit'];
|
2026-06-04 14:19:54 +03:30
|
|
|
if (static::hasTypeColumn()) {
|
|
|
|
|
$cols[] = 'type';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $cols;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-24 14:03:11 +00:00
|
|
|
protected $fillable = [
|
|
|
|
|
'key',
|
|
|
|
|
'title_fa',
|
2026-02-09 14:09:19 +03:30
|
|
|
'is_active',
|
|
|
|
|
'description',
|
2026-01-24 14:03:11 +00:00
|
|
|
'value',
|
2026-06-04 14:19:54 +03:30
|
|
|
'value_json',
|
|
|
|
|
'type',
|
2026-01-24 14:03:11 +00:00
|
|
|
];
|
|
|
|
|
protected $casts = [
|
2026-02-09 14:09:19 +03:30
|
|
|
'value_json'=>'array',
|
|
|
|
|
'is_active'=>'boolean',
|
2026-01-24 14:03:11 +00:00
|
|
|
];
|
|
|
|
|
}
|