Files
BetiX/app/Models/AppSetting.php
Dolo 0280278978
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
Initialer Laravel Commit für BetiX
2026-04-04 18:01:50 +02:00

31 lines
644 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AppSetting extends Model
{
use HasFactory;
protected $table = 'app_settings';
protected $fillable = ['key', 'value'];
protected $casts = [
'value' => 'array',
];
public static function get(string $key, $default = null)
{
$row = static::query()->where('key', $key)->first();
return $row?->value ?? $default;
}
public static function put(string $key, $value): void
{
static::updateOrCreate(['key' => $key], ['value' => $value]);
}
}