初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
protected $fillable = ['key', 'value', 'group'];
/**
* 读取设置值,未设置时返回默认值。
*/
public static function get(string $key, ?string $default = null): ?string
{
$row = static::where('key', $key)->first();
if (!$row) {
return $default;
}
return $row->value;
}
/**
* 写入或更新设置值。
*/
public static function set(string $key, ?string $value, string $group = 'general'): void
{
static::updateOrCreate(
['key' => $key],
['value' => $value, 'group' => $group]
);
}
}