|
@@ -101,13 +101,24 @@ class SourceShool extends SourceShoolModel
|
|
|
return $this->where(function ($query) use ($param){
|
|
return $this->where(function ($query) use ($param){
|
|
|
$keyword = isset($param['keyword'])? trim($param['keyword']) : '';
|
|
$keyword = isset($param['keyword'])? trim($param['keyword']) : '';
|
|
|
if($keyword){
|
|
if($keyword){
|
|
|
- $query->where('source_shools_name','like',"%{$keyword}%")
|
|
|
|
|
- ->whereOr('address','like',"%{$keyword}%");
|
|
|
|
|
|
|
+ $query->where(function($query) use($keyword){
|
|
|
|
|
+ $query->where('source_shools_name','like',"%{$keyword}%")
|
|
|
|
|
+ ->whereOr('address','like',"%{$keyword}%");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $userId = isset($param['user_id'])? intval($param['user_id']) : 0;
|
|
|
|
|
+ if($userId>0){
|
|
|
|
|
+ $query->whereNotIn('source_shools_id', SourceShoolApply::getSchoolsByUser($userId));
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
->field($field?:'source_shools_id as id,source_shools_name as school_name,students_num')
|
|
->field($field?:'source_shools_id as id,source_shools_name as school_name,students_num')
|
|
|
- ->order('students_num desc,source_shools_id desc')
|
|
|
|
|
- ->select();
|
|
|
|
|
|
|
+ ->order('students_num desc,id desc')
|
|
|
|
|
+ ->select()
|
|
|
|
|
+ ->each(function($item, $k) use ($param){
|
|
|
|
|
+ $userId = isset($param['user_id'])? intval($param['user_id']) : 0;
|
|
|
|
|
+ $item['is_apply'] = $userId? SourceShoolApply::checkApplyByUser($userId, $item['id']) : 0;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|