quanwei
2 days ago 73b874c72ad55eb9eef21c36160ac0de58f0189e
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
<?php
 
namespace app\shop\controller\setting;
 
use app\shop\controller\Controller;
use app\shop\model\settings\Setting as SettingModel;
 
/**
 * 存储控制器
 */
class Storage extends Controller
{
    /**
     * 存储设置
     */
    public function index()
    {
        if($this->request->isGet()){
            return $this->fetchData();
        }
        $model = new SettingModel;
        $data = $this->postData();
        $arr['default'] = $data['radio'];
        $arr['max_image'] = $data['max_image'];
        $arr['max_video'] = $data['max_video'];
        $arr['engine'] = $data['engine'];
        if ($model->edit('storage', $arr)) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }
 
    /**
     * 获取存储配置
     */
    public function fetchData()
    {
        $key = 'storage';
        $vars['values'] = SettingModel::getItem($key);
        return $this->renderSuccess('', compact('vars'));
    }
 
}