TableQrcodeDao.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\activity\table;
  12. use app\dao\BaseDao;
  13. use app\model\activity\table\TableQrcode;
  14. /**
  15. * 桌码
  16. * Class TableQrcodeDao
  17. * @package app\dao\activity\table
  18. */
  19. class TableQrcodeDao extends BaseDao
  20. {
  21. /**
  22. * 设置模型
  23. * @return string
  24. */
  25. protected function setModel(): string
  26. {
  27. return TableQrcode::class;
  28. }
  29. /**条件处理
  30. * @param array $where
  31. * @return \crmeb\basic\BaseModel|mixed|\think\Model
  32. */
  33. public function search(array $where = [])
  34. {
  35. return parent::search($where)->when(isset($where['store_id']) && $where['store_id'], function ($query) use ($where) {
  36. $query->where('store_id', $where['store_id']);
  37. })->when(isset($where['cate_id']) && $where['cate_id'], function ($query) use ($where) {
  38. $query->where('cate_id', $where['cate_id']);
  39. })->when(isset($where['is_del']), function ($query) use ($where) {
  40. $query->where('is_del', $where['is_del']);
  41. });
  42. }
  43. /**获取桌码列表
  44. * @param array $where
  45. * @param int $storeId
  46. * @param int $page
  47. * @param int $limit
  48. * @return array
  49. * @throws \think\db\exception\DataNotFoundException
  50. * @throws \think\db\exception\DbException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. */
  53. public function getList(array $where, int $page, int $limit,array $with)
  54. {
  55. return $this->search($where)->when(count($with), function ($query) use ($with) {
  56. $query->with($with);
  57. })->page($page,$limit)->order('add_time Asc')->select()->toArray();
  58. }
  59. /**获取座位信息
  60. * @param array $where
  61. * @param array $with
  62. * @return array|\crmeb\basic\BaseModel|mixed|\think\Model|null
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\DbException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. */
  67. public function getTableCodeOne(array $where, array $with)
  68. {
  69. return $this->getModel()->where($where)->when(count($with), function ($query) use ($with) {
  70. $query->with($with);
  71. })->find();
  72. }
  73. }