/
Config.php
68 lines (59 loc) · 1.8 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议 https://mit-license.org
// +----------------------------------------------------------------------
// | github开源项目:https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller\system;
use app\admin\model\SystemConfig;
use app\admin\service\TriggerService;
use app\common\controller\AdminController;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;
/**
* Class Config
* @package app\admin\controller\system
* @ControllerAnnotation(title="系统配置管理")
*/
class Config extends AdminController
{
public function __construct(App $app)
{
parent::__construct($app);
$this->model = new SystemConfig();
}
/**
* @NodeAnotation(title="列表")
*/
public function index()
{
return $this->fetch();
}
/**
* @NodeAnotation(title="保存")
*/
public function save()
{
$this->checkPostRequest();
$post = $this->request->post();
try {
foreach ($post as $key => $val) {
$this->model
->where('name', $key)
->update([
'value' => $val,
]);
}
TriggerService::updateMenu();
TriggerService::updateSysconfig();
} catch (\Exception $e) {
$this->error('保存失败');
}
$this->success('保存成功');
}
}