| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\admin\controller\system;
- use app\common\controller\AdminController;
- use app\http\IResponse;
- class Setting extends AdminController
- {
- public function xdebug()
- {
- return IResponse::success();
- }
- /**
- * 获取设置
- *
- * @author 许祖兴 < zuxing.xu@lettered.cn>
- *
- * @return mixed
- */
- public function index()
- {
- if ($this->request->param('group')){
- $settings = model('common/SystemConfig')->where(['group' => $this->request->param('group')])
- ->order('sort,id')
- ->column('id,name,title,group,value,type,options,tips');
- //
- $lists = [];
- foreach ($settings as $k => $v) {
- if (!empty($v['options'])) {
- $v['options'] = parse_attr($v['options']);
- }
- if ($v['type'] == 'checkbox') {
- $v['value'] = explode(',', $v['value']);
- }
- $v['tips'] = htmlspecialchars_decode( $v['tips']);
- $lists[] = $v;
- }
- // 更新缓存
- model('common/SystemConfig')->getAppConfig('');
- return IResponse::success($lists);
- }
- $tabData= [];
- foreach (config('develop.config_group') as $key => $value) {
- $tabData[] = [
- 'name' => $value,
- 'policy' => $key
- ];
- }
- return IResponse::success($tabData);
- }
- /**
- * 更新设置
- *
- * @author 许祖兴 < zuxing.xu@lettered.cn>
- * @param string $group
- * @return mixed
- */
- public function update($group = 'system')
- {
- $data = $this->request->param('set/a');
- // halt($data);
- foreach ($data as $name => $value) {
- //$config = model('common/SystemConfig')::get(['name' => $name]);
- model('common/SystemConfig')::update(['value' => $value],['name' => $name]);
- }
- // 更新配置缓存
- model('common/SystemConfig')->getAppConfig('', true);
- return IResponse::success('更新系统配置成功');
- }
- }
|