AdminLockBookController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\teahouse\controller;
  12. use app\teahouse\model\LockBookModel;
  13. use cmf\controller\AdminBaseController;
  14. class AdminLockBookController extends AdminBaseController
  15. {
  16. public function index()
  17. {
  18. $param = $this->request->param();
  19. //搜索条件
  20. $where = [];
  21. if (!empty($param['lock_name'])) {
  22. $where[] = ['lock_name', 'like', "%{$param['lock_name']}%"];
  23. }
  24. if (!empty($param['user_name'])) {
  25. $where[] = ['user_name', 'like', "%{$param['user_name']}%"];
  26. }
  27. if (!empty($param['is_use'])) {
  28. $where[] = ['is_use', '=', $param['is_use']];
  29. }
  30. $list = LockBookModel::where($where)
  31. ->append(['is_use_text'])
  32. ->order('id desc')
  33. ->paginate(10, false, ['query' => $param]);
  34. $this->assign('is_use', isset($param['is_use']) ? $param['is_use'] : 0);
  35. $this->assign('lock_name', isset($param['lock_name']) ? $param['lock_name'] : '');
  36. $this->assign('user_name', isset($param['user_name']) ? $param['user_name'] : '');
  37. $this->assign('list', $list->items());
  38. $this->assign('page', $list->render());
  39. return $this->fetch();
  40. }
  41. public function setStatus()
  42. {
  43. $ids = $this->request->param('ids');
  44. LockBookModel::update(['is_use' => 1], ['id' => $ids]);
  45. $this->success('操作成功');
  46. }
  47. }