123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- declare (strict_types = 1);
- namespace app\model\system;
- use Closure;
- use library\basic\BaseModel;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class MemberFollow extends BaseModel
- {
- /**
- * 获取列表数据
- * @param $page
- * @param $where
- * @param $pageCount
- * @param $desc
- */
- public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = ''){
- $data = $this
- ->field("table_member_follow.*,sa.username")
- ->when(!empty($where),function ($query) use($where){
- foreach ($where as $k=>$v) {
- if($v instanceof Closure) {
- $v($query);
- } else {
- if(is_array($v)) {
- //whereLike
- if($v[1] == 'whereLike') {
- if(!empty($v[0]))
- $query->whereLike($k,$v[0]);
- continue;
- }
- if($v[1] == 'whereBetween') {
- if(!empty($v[0])) $query->whereBetween($k,$v[0]);
- continue;
- }
- $bool = false;
- eval('$bool = '.$v[1].'($v[0]);');
- if($bool) {
- $query->where($k,$v[0]);
- }
- } else {
- $query->where($k,$v);
- }
- }
- }
- })
- ->join('system_admin sa','sa.id = table_member_follow.admin_id')
- ->order($desc)
- ->paginate(['list_rows'=>$pageCount,'page'=>$page])
- ->toArray();
- // echo $this->getLastSql();
- return [$data['total'],$data['data']];
- }
- }
|