🔄 در حال انجام: تست دستی Filament ⏸️ بلاک: مهاجرت ۳۹۵۰ رکورد (منتظر فایل اکسل اصلاحشده) ⏸️ بلاک: پلاگین وردپرس (بعد از تست کامل API)
47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class SystemSetting extends Model
|
|
{
|
|
protected $fillable = [
|
|
'key',
|
|
'value',
|
|
'description',
|
|
'updated_by',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'value' => 'decimal:4',
|
|
];
|
|
}
|
|
|
|
public function updatedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'updated_by');
|
|
}
|
|
|
|
public static function get(string $key, $default = null)
|
|
{
|
|
$setting = static::where('key', $key)->first();
|
|
return $setting ? $setting->value : $default;
|
|
}
|
|
|
|
public static function set(string $key, $value, ?string $description = null, ?int $updatedBy = null): void
|
|
{
|
|
static::updateOrCreate(
|
|
['key' => $key],
|
|
[
|
|
'value' => $value,
|
|
'description' => $description,
|
|
'updated_by' => $updatedBy,
|
|
]
|
|
);
|
|
}
|
|
}
|