field( "t.*,(SELECT mobile FROM table_member where uid = t.uid) as member_mobile," . "(SELECT name from table_site where sassid = t.sassid) as site_name,". "(SELECT name from table_warehouse where id = t.warehouse_id) as warehouse_name" ) ->alias("t") ->when(!empty($where),function ($query) use($where){ if($where['orderType'] == 2) { $query->where('t.is_type',1); } if($where['orderType'] == 1) { $query->where('t.is_type',0); } if(!empty($where['mobile'])){ $query->where('t.code',"%".$where['mobile']."%"); } if(!empty($where['uid'])){ $query->where('t.uid',$where['uid']); } if(!empty($where['type'])){ $query->where('t.type',$where['type']); } if(!empty($where['sassids'])){ $query->whereIn('t.sassid',join(',',$where['sassids'])); } }) ->order($desc) ->paginate(['list_rows'=>$pageCount,'page'=>$page]) ->toArray(); // echo $this->getLastSql(); return [$data['total'],$data['data']]; } }