'desc'],$pagesize=3) { $currentQuery = $this->model; /*企业名称*/ if(isset($search['companyName']) && ! empty($search['companyName'])) { $keywords = str_replace(',','|',$search['companyName']); $currentQuery = $currentQuery->where(function ($query) use ($keywords) { $query->where('companyName' , 'REGEXP', $keywords); }); } /*所在地区*/ if(isset($search['district']) && ! empty($search['district'])) { $district = str_replace(',','|',$search['district']); $currentQuery = $currentQuery->where(function ($query) use ($district) { $query->where('district','REGEXP', $district); }); } /*企业类型*/ if(isset($search['entType']) && ! empty($search['entType'])) { $entType = str_replace(',','|',$search['entType']); $currentQuery = $currentQuery->where(function ($query) use ($entType) { $query->where('entType','REGEXP',$entType); }); } /*经营状态*/ if(isset($search['openStatus']) && ! empty($search['openStatus'])) { $openStatus = str_replace(',','|',$search['openStatus']); $currentQuery = $currentQuery->where(function ($query) use ($openStatus) { $query->where('openStatus','REGEXP',$openStatus); }); } /*所属行业*/ if(isset($search['industry']) && ! empty($search['industry'])) { $industry= str_replace(',','|',$search['industry']); $currentQuery = $currentQuery->where(function ($query) use ($industry) { $query->where('industry','REGEXP',$industry); }); } /*注册资本*/ if(isset($search['regCapital']) && ! empty($search['regCapital'])) { $regCapital = explode('-',$search['regCapital']); $currentQuery = $currentQuery->where(function ($query) use ($regCapital) { if(!$regCapital[1]){ $query->where('regCapital','>=',(int)$regCapital[0]); }else{ $query->where('regCapital','>=',(int)$regCapital[0]) ->where('regCapital','<',(int)$regCapital[1]); } }); } if($orderby && is_array($orderby)){ foreach ($orderby AS $field => $value){ $currentQuery = $currentQuery->orderBy($field, $value); } } $currentQuery = $currentQuery->paginate($pagesize); return $currentQuery; } }