Service.php 800 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\admin\controller\setting;
  3. use app\admin\controller\Controller;
  4. use app\admin\model\settings\Setting as SettingModel;
  5. /**
  6. * 客服配置控制器
  7. */
  8. class Service 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. if ($model->add($this->request->param())) {
  20. return $this->renderSuccess('操作成功');
  21. }
  22. return $this->renderError($model->getError() ?: '操作失败');
  23. }
  24. /**
  25. * 获取客服配置
  26. */
  27. public function fetchData()
  28. {
  29. $vars['values'] = SettingModel::getSysConfig();
  30. return $this->renderSuccess('', compact('vars'));
  31. }
  32. }