System.php 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare (strict_types = 1);
  3. /**
  4. * +----------------------------------------------------------------------
  5. * | 管理员日志控制器
  6. * +----------------------------------------------------------------------
  7. */
  8. namespace app\controller\sys;
  9. // 引入框架内置类
  10. use think\facade\View;
  11. use app\model\System as SystemModel;
  12. use app\utils\ReUtils;
  13. class System extends Base
  14. {
  15. public function index()
  16. {
  17. $data = SystemModel::find(1);
  18. View::assign('data', $data);
  19. return View::fetch();
  20. }
  21. public function save($id = 0)
  22. {
  23. if ($this->request->isPost()) {
  24. $params = $this->request->param();
  25. try {
  26. SystemModel::update($params, ['id' => 1]);
  27. return ReUtils::success();
  28. } catch (\Exception $e) {
  29. return ReUtils::error($e->getMessage());
  30. }
  31. }
  32. }
  33. }