CutterTaskDao.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\extra\dao\cutter;
  3. use app\extra\basic\Dao;
  4. use app\model\cutter\CutterTask;
  5. class CutterTaskDao extends Dao
  6. {
  7. /**
  8. * 设置模型
  9. * @return string
  10. */
  11. protected function setModel(): string
  12. {
  13. return CutterTask::class;
  14. }
  15. public function getList($where,string $field = '*',int $page = 0, int $limit = 0,string $order='id desc')
  16. {
  17. return $this->getModel()->where($where)->field($field)->when($page&&$limit,function($query)use($page,$limit){
  18. $query->page($page,$limit);
  19. })->with(['grade'=>function ($query) {
  20. $query->field('name,icon,grade,color');
  21. },'label'=>function ($query) {
  22. $query->field('id,label_name');
  23. }])->withCount(['orderCount'=>'people'])->orderRaw($order)->select();
  24. }
  25. public function getInfo(array $where,string $field = '*')
  26. {
  27. return $this->getModel()->where($where)->field($field)->with(['kefu'=>function ($query) {
  28. $query->field('id,name,wechat,qrcode');
  29. },'grade'=>function ($query) {
  30. $query->field('name,icon,grade,color');
  31. },'label'=>function ($query) {
  32. $query->field('id,label_name');
  33. }])->withCount(['orderCount'=>'people'])->findOrEmpty();
  34. }
  35. }