Storage.php 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\shop\controller\setting;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\settings\Setting as SettingModel;
  5. /**
  6. * 存储控制器
  7. */
  8. class Storage extends Controller
  9. {
  10. /**
  11. * 存储设置
  12. */
  13. public function index()
  14. {
  15. if($this->request->isGet()){
  16. return $this->fetchData();
  17. }
  18. $model = new SettingModel;
  19. $data = $this->postData();
  20. $arr['default'] = $data['radio'];
  21. $arr['engine'] = $data['engine'];
  22. if ($model->edit('storage', $arr)) {
  23. return $this->renderSuccess('操作成功');
  24. }
  25. return $this->renderError($model->getError() ?: '操作失败');
  26. }
  27. /**
  28. * 获取存储配置
  29. */
  30. public function fetchData()
  31. {
  32. $key = 'storage';
  33. $vars['values'] = SettingModel::getItem($key);
  34. return $this->renderSuccess('', compact('vars'));
  35. }
  36. }