Banner.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace app\mall\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 轮播图
  7. * Class Goods
  8. * @package app\mall\controller
  9. */
  10. class Banner extends Controller
  11. {
  12. /**
  13. * 绑定数据表
  14. * @var string
  15. */
  16. protected $table = 'StoreBanner';
  17. /**
  18. * 轮播图列表
  19. * @auth true
  20. * @menu true
  21. * @throws \think\Exception
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. * @throws \think\exception\DbException
  25. * @throws \think\exception\PDOException
  26. */
  27. public function index()
  28. {
  29. $this->title = '轮播图列表';
  30. $this->place_desc = ['','视频首页'];
  31. $query = $this->_query($this->table)->where('is_deleted',0);
  32. $query->like('name');
  33. if(input('place')) $query->where('place',input('place'));
  34. $query->order(' sort desc , id asc')->page();
  35. }
  36. /**
  37. * 数据列表处理
  38. * @auth true
  39. * @menu true
  40. * @param array $data
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. */
  45. protected function _index_page_filter(&$data)
  46. {
  47. }
  48. /**
  49. * 添加轮播图
  50. * @auth true
  51. * @menu true
  52. * @throws \think\Exception
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @throws \think\exception\DbException
  56. * @throws \think\exception\PDOException
  57. */
  58. public function add()
  59. {
  60. $this->place_desc = ['','视频首页'];
  61. $this->title = '添加轮播图';
  62. $this->_form($this->table, 'form');
  63. }
  64. /**
  65. * 编辑轮播图
  66. * @auth true
  67. * @menu true
  68. * @throws \think\Exception
  69. * @throws \think\db\exception\DataNotFoundException
  70. * @throws \think\db\exception\ModelNotFoundException
  71. * @throws \think\exception\DbException
  72. * @throws \think\exception\PDOException
  73. */
  74. public function edit()
  75. {
  76. $this->place_desc =['','视频首页'];
  77. $this->title = '编辑轮播图';
  78. $this->_form($this->table, 'form');
  79. }
  80. /**
  81. * 启用
  82. * @auth true
  83. * @menu true
  84. * @throws \think\Exception
  85. * @throws \think\exception\PDOException
  86. */
  87. public function enable()
  88. {
  89. $this->_save($this->table, ['status' => 1]);
  90. }
  91. /**
  92. * 删除
  93. * @auth true
  94. * @menu true
  95. * @throws \think\Exception
  96. * @throws \think\exception\PDOException
  97. */
  98. public function del()
  99. {
  100. $this->_save($this->table, ['is_deleted' => 1]);
  101. }
  102. /**
  103. * 表单数据处理
  104. * @auth true
  105. * @menu true
  106. * @param array $data
  107. */
  108. protected function _form_filter(&$data)
  109. {
  110. $data['create_at'] = date('Y-m-d H:i:s');
  111. }
  112. }