SystemTicketDao.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\dao\system;
  3. use app\dao\BaseDao;
  4. use app\model\system\SystemTicket;
  5. class SystemTicketDao extends BaseDao
  6. {
  7. protected function setModel(): string
  8. {
  9. return SystemTicket::class;
  10. }
  11. public function getConditionModel($where)
  12. {
  13. return $this->getModel()->where('is_del', 0)
  14. ->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  15. $query->where('print_name', 'like', '%' . $where['keyword'] . '%');
  16. })->when(isset($where['type']) && $where['type'] != 0, function ($query) use ($where) {
  17. $query->where('type', $where['type']);
  18. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  19. $query->where('status', $where['status']);
  20. })->when(isset($where['print_type']) && $where['print_type'] != 0, function ($query) use ($where) {
  21. $query->where('print_type', $where['print_type']);
  22. });
  23. }
  24. public function ticketList($where, $page = 0, $limit = 0)
  25. {
  26. return $this->getConditionModel($where)->order('id desc')->when($page != 0, function ($query) use ($page, $limit) {
  27. $query->page($page, $limit);
  28. })->select()->toArray();
  29. }
  30. public function ticketCount($where)
  31. {
  32. return $this->getConditionModel($where)->count();
  33. }
  34. }