LiveBanner.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\store\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 轮播图
  7. * Class Goods
  8. * @package app\store\controller
  9. */
  10. class LiveBanner extends Controller
  11. {
  12. /**
  13. * 绑定数据表
  14. * @var string
  15. */
  16. protected $table = 'LiveBanner';
  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. $query = $this->_query($this->table)->where('is_deleted',0);
  31. $query->like('name');
  32. $query->order(' sort desc , id desc')->page();
  33. }
  34. /**
  35. * 数据列表处理
  36. * @auth true
  37. * @menu true
  38. * @param array $data
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. */
  43. protected function _index_page_filter(&$data)
  44. {
  45. }
  46. /**
  47. * 添加商品
  48. * @auth true
  49. * @menu true
  50. * @throws \think\Exception
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @throws \think\exception\DbException
  54. * @throws \think\exception\PDOException
  55. */
  56. public function add()
  57. {
  58. $this->title = '添加商品';
  59. $this->goods_cate = Db::table('store_live_cate')
  60. ->field('id,title')
  61. ->where('status',1)
  62. ->where('is_deleted',0)
  63. ->order('sort desc , id desc')
  64. ->select();
  65. $this->_form($this->table, 'form');
  66. }
  67. /**
  68. * 编辑商品
  69. * @auth true
  70. * @menu true
  71. * @throws \think\Exception
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. * @throws \think\exception\DbException
  75. * @throws \think\exception\PDOException
  76. */
  77. public function edit()
  78. {
  79. $this->title = '编辑商品';
  80. $this->goods_cate = Db::table('store_live_cate')
  81. ->field('id,title')
  82. ->where('status',1)
  83. ->where('is_deleted',0)
  84. ->order('sort desc , id desc')
  85. ->select();
  86. $this->_form($this->table, 'form');
  87. }
  88. /**
  89. * 禁用
  90. * @auth true
  91. * @menu true
  92. * @throws \think\Exception
  93. * @throws \think\exception\PDOException
  94. */
  95. public function forbidden()
  96. {
  97. $this->_save($this->table, ['status' => '0']);
  98. }
  99. /**
  100. * 启用
  101. * @auth true
  102. * @menu true
  103. * @throws \think\Exception
  104. * @throws \think\exception\PDOException
  105. */
  106. public function enable()
  107. {
  108. $this->_save($this->table, ['status' => 1]);
  109. }
  110. /**
  111. * 删除
  112. * @auth true
  113. * @menu true
  114. * @throws \think\Exception
  115. * @throws \think\exception\PDOException
  116. */
  117. public function del()
  118. {
  119. $this->_save($this->table, ['is_deleted' => 1]);
  120. }
  121. /**
  122. * 表单数据处理
  123. * @auth true
  124. * @menu true
  125. * @param array $data
  126. */
  127. protected function _form_filter(&$data)
  128. {
  129. $data['create_at'] = date('Y-m-d H:i:s');
  130. }
  131. }