system settings
This commit is contained in:
parent
3f71eef985
commit
a45a119db8
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Admin\Http\Controllers;
|
||||
|
||||
use Beike\Repositories\SettingRepo;
|
||||
use Beike\Repositories\SystemSettingRepo;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SettingController extends Controller
|
||||
|
|
@ -23,7 +24,8 @@ class SettingController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
return setting("system");
|
||||
$settings = SystemSettingRepo::getList();
|
||||
dd($settings);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class SettingRepo
|
|||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取插件默认字段
|
||||
*
|
||||
|
|
@ -57,6 +58,12 @@ class SettingRepo
|
|||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单个插件所有字段
|
||||
* @param $pluginCode
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getPluginColumns($pluginCode)
|
||||
{
|
||||
return Setting::query()
|
||||
|
|
@ -66,12 +73,27 @@ class SettingRepo
|
|||
->keyBy('name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单个插件状态
|
||||
*
|
||||
* @param $pluginCode
|
||||
* @return bool
|
||||
*/
|
||||
public static function getPluginStatus($pluginCode): bool
|
||||
{
|
||||
$status = plugin_setting("{$pluginCode}.status");
|
||||
return (bool)$status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新设置
|
||||
*
|
||||
* @param $type
|
||||
* @param $code
|
||||
* @param $fields
|
||||
*/
|
||||
public static function update($type, $code, $fields)
|
||||
{
|
||||
$columns = array_keys($fields);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* SystemSettingRepo.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-25 20:26:15
|
||||
* @modified 2022-07-25 20:26:15
|
||||
*/
|
||||
|
||||
namespace Beike\Repositories;
|
||||
|
||||
class SystemSettingRepo
|
||||
{
|
||||
/**
|
||||
* 获取系统设置
|
||||
*/
|
||||
public static function getList(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name' => 'country_id',
|
||||
'label' => '默认国家',
|
||||
'type' => 'select',
|
||||
'required' => true,
|
||||
'options' => [
|
||||
['value' => '1', 'label' => '中国'],
|
||||
['value' => '2', 'label' => '美国']
|
||||
],
|
||||
'value' => old('country_id', system_setting('base.country_id', '1')),
|
||||
'description' => '默认国家选择',
|
||||
],
|
||||
[
|
||||
'name' => 'locale',
|
||||
'label' => '默认语言',
|
||||
'type' => 'select',
|
||||
'required' => true,
|
||||
'options' => [
|
||||
['value' => 'zh_cn', 'label' => '简体中文'],
|
||||
['value' => 'en', 'label' => '英文']
|
||||
],
|
||||
'value' => old('locale', system_setting('base.locale', 'zh_cn')),
|
||||
'description' => '密钥(Secret key)',
|
||||
],
|
||||
[
|
||||
'name' => 'admin_name',
|
||||
'label' => '后台目录',
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'value' => old('admin_name', system_setting('base.admin_name', 'admin')),
|
||||
'description' => '管理后台目录,默认为admin',
|
||||
],
|
||||
[
|
||||
'name' => 'theme',
|
||||
'label' => '主题模板',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
['value' => 'default', 'label' => '默认主题'],
|
||||
['value' => 'black', 'label' => '黑色主题']
|
||||
],
|
||||
'value' => old('theme', system_setting('base.theme', 'default')),
|
||||
'required' => true,
|
||||
'description' => '主题模板选择',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue