SpreadApplyDao.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\dao\agent;
  3. use app\dao\BaseDao;
  4. use app\model\agent\SpreadApply;
  5. class SpreadApplyDao extends BaseDao
  6. {
  7. protected function setModel(): string
  8. {
  9. return SpreadApply::class;
  10. }
  11. public function getConditionModel($where)
  12. {
  13. return $this->getModel()->where('is_del', 0)
  14. ->when($where['status'] !== '' && $where['status'] !== 'all', function ($query) use ($where) {
  15. $query->where('status', $where['status']);
  16. })->when($where['keyword'] !== '', function ($query) use ($where) {
  17. $query->whereLike('uid|nickname|real_name|phone', $where['keyword']);
  18. });
  19. }
  20. public function applyList($where, $page = 0, $limit = 0)
  21. {
  22. return $this->getConditionModel($where)->order('id desc')->when($page != 0, function ($query) use ($page, $limit) {
  23. $query->page($page, $limit);
  24. })->select()->toArray();
  25. }
  26. public function applyCount($where)
  27. {
  28. return $this->getConditionModel($where)->count();
  29. }
  30. }