Files
Xboard/app/Helpers/Functions.php

43 lines
1.0 KiB
PHP
Raw Normal View History

2023-11-17 14:44:01 +08:00
<?php
use App\Support\Setting;
use Illuminate\Support\Facades\App;
2023-11-17 14:44:01 +08:00
if (! function_exists('admin_setting')) {
/**
* 获取或保存配置参数.
*
* @param string|array $key
* @param mixed $default
* @return App\Support\Setting|mixed
*/
function admin_setting($key = null, $default = null)
{
$setting = Setting::getInstance();
2023-11-17 14:44:01 +08:00
if ($key === null) {
return $setting->toArray();
2023-11-17 14:44:01 +08:00
}
if (is_array($key)) {
$setting->save($key);
return '';
2023-11-17 14:44:01 +08:00
}
2023-11-17 14:44:01 +08:00
$default = config('v2board.'. $key) ?? $default;
return $setting->get($key) ?? $default;
}
}
if (! function_exists('admin_settings_batch')) {
/**
* 批量获取配置参数,性能优化版本
*
* @param array $keys 配置键名数组
* @return array 返回键值对数组
*/
function admin_settings_batch(array $keys): array
{
return Setting::getInstance()->getBatch($keys);
2023-11-17 14:44:01 +08:00
}
}