Home.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\controller\wwh;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. *
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Home extends Backend
  11. {
  12. /**
  13. * 查看
  14. */
  15. public function index()
  16. {
  17. $data = Db::name('wwh_home')->where('id', 1)->find();
  18. $this->assign('data', $data);
  19. return $this->view->fetch();
  20. }
  21. /**
  22. * 关于我们修改
  23. */
  24. public function enterprise()
  25. {
  26. $s=[
  27. 'about_title'=>input('about_title'),
  28. 'introduction'=>input('introduction'),
  29. 'title1'=>input('title1'),
  30. 'description1'=>input('description1'),
  31. 'title2'=>input('title2'),
  32. 'description2'=>input('description2'),
  33. 'title3'=>input('title3'),
  34. 'description3'=>input('description3'),
  35. ];
  36. $test = Db::name('wwh_home')->where('id', 1)->find();
  37. if (empty($test)) {
  38. $data = Db::name('wwh_home')->insert($s);
  39. } else {
  40. $data = Db::name('wwh_home')->where('id', 1)->setField($s);
  41. }
  42. if ($data) {
  43. $this->success('保存成功');
  44. } else {
  45. $this->error('未检测到数据变动');
  46. }
  47. }
  48. }