SysAdPositionModel.php 993 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Ad\Models;
  3. use App\Models\BaseModel;
  4. class SysAdPositionModel extends BaseModel
  5. {
  6. protected $table = 'sys_ad_position';
  7. /**
  8. * 获取广告列表
  9. * */
  10. public function getAdPositionList($params){
  11. list($pageSize, $page, $skip) = $this->getPaginatorParams($params);
  12. $where=[];
  13. if(isset($params['status'])){
  14. $where[]=['a.status','=',$params['status']];
  15. }else{
  16. $where[]=['a.status','<',2];
  17. }
  18. $query= $this->newInstance()->alias('a')->where($where);
  19. $totalCount = $query->count();
  20. $list= $query->skip($skip)
  21. ->limit($pageSize)
  22. ->selectRaw('a.*')
  23. ->orderBy('a.update_time','desc')
  24. ->get();
  25. if(!empty($list)){
  26. $list=$list->toArray();
  27. }else{
  28. $list=[];
  29. }
  30. $result = $this->buildPaginator($list, $skip, $page, $pageSize, $totalCount);
  31. return $result;
  32. }
  33. }