This commit is contained in:
cjd
2026-02-05 22:22:10 +08:00
parent fef9fe0c31
commit bf3a2e6971
273 changed files with 30605 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class SiteSetting extends Model
{
use HasFactory;
protected $fillable = [
'key',
'value',
];
public static function value(string $key, $default = null)
{
return cache()->remember("site_setting_{$key}", 600, function () use ($key, $default) {
$setting = static::where('key', $key)->first();
return $setting?->value ?? $default;
});
}
protected static function booted()
{
static::saved(function (SiteSetting $setting): void {
cache()->forget("site_setting_{$setting->key}");
});
}
}