搭建轻舟一期门户、后台和统一登录。
让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function get(string $key, ?string $default = null): ?string
|
||||
{
|
||||
$all = Cache::remember('qz.settings', 60, function () {
|
||||
return Setting::query()->pluck('value', 'key')->all();
|
||||
});
|
||||
|
||||
return $all[$key] ?? $default;
|
||||
}
|
||||
|
||||
public static function bool(string $key, bool $default = false): bool
|
||||
{
|
||||
$value = self::get($key);
|
||||
if ($value === null) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return in_array(strtolower($value), ['1', 'true', 'yes', 'on'], true);
|
||||
}
|
||||
|
||||
public static function flush(): void
|
||||
{
|
||||
Cache::forget('qz.settings');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user