123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * 挖掘线索
- * @author system
- * @version 1.0
- * @date 2018-11-19 08:23:08
- *
- */
- namespace App\Repositories\Company;
- use App\Repositories\Base\Repository;
- class InfoRepository extends Repository {
- public function model() {
- return \App\Models\CompanyInfoModel::class;
- }
- public function searchCompany(array $search,array $orderby=['id'=>'desc'],$pagesize=10)
- {
- $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;
- }
-
- }
|