32 lines
841 B
PHP
32 lines
841 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* Тонкий read-хелпер для общесистемных настроек (table system_settings).
|
|
* Значения хранятся строками; type — подсказка для UI/каста.
|
|
*/
|
|
final class SystemSettings
|
|
{
|
|
public static function get(string $key, ?string $default = null): ?string
|
|
{
|
|
$row = DB::table('system_settings')->where('key', $key)->first();
|
|
|
|
return $row === null ? $default : (string) $row->value;
|
|
}
|
|
|
|
public static function bool(string $key, bool $default = false): bool
|
|
{
|
|
$val = self::get($key);
|
|
if ($val === null) {
|
|
return $default;
|
|
}
|
|
|
|
return in_array(strtolower($val), ['1', 'true', 'yes', 'on'], true);
|
|
}
|
|
}
|