|
|
@@ -453,11 +453,20 @@ class UseScopeBaseModel extends Model
|
|
|
$query->where('top_depart_id', $top_depart_id);
|
|
|
}
|
|
|
}else{
|
|
|
+ $query->where(function ($q) use ($top_depart_id, $depart_range, $top_depart) {
|
|
|
+ $q->where(function ($q2) use ($top_depart_id, $depart_range) {
|
|
|
+ $q2->where('top_depart_id', $top_depart_id)
|
|
|
+ ->whereIn('depart_id', $depart_range);
|
|
|
+ })
|
|
|
+ ->orWhere('top_depart_id', $top_depart);
|
|
|
+ })
|
|
|
+ ->whereNotIn('id', $id);
|
|
|
+
|
|
|
//某个分社全部 去掉不可见数
|
|
|
- $query->where('top_depart_id', $top_depart_id)
|
|
|
- ->whereIn('depart_id', $depart_range)
|
|
|
- ->orWhere('top_depart_id',$top_depart)
|
|
|
- ->whereNotIn('id', $id);
|
|
|
+// $query->where('top_depart_id', $top_depart_id)
|
|
|
+// ->whereIn('depart_id', $depart_range)
|
|
|
+// ->orWhere('top_depart_id',$top_depart)
|
|
|
+// ->whereNotIn('id', $id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -499,15 +508,28 @@ class UseScopeBaseModel extends Model
|
|
|
$query->whereIn('depart_id', $depart_range);
|
|
|
}else{
|
|
|
//查看某个分社
|
|
|
- $query->where('top_depart_id', $top_depart_id)
|
|
|
- ->orWhere('top_depart_id',$top_depart);
|
|
|
+// $query->where('top_depart_id', $top_depart_id)
|
|
|
+// ->orWhere('top_depart_id',$top_depart);
|
|
|
+
|
|
|
+ $query->where(function ($q) use ($top_depart_id, $top_depart) {
|
|
|
+ $q->where('top_depart_id', $top_depart_id)
|
|
|
+ ->orWhere('top_depart_id', $top_depart);
|
|
|
+ });
|
|
|
}
|
|
|
}else{
|
|
|
- //某个分社全部 去掉不可见数
|
|
|
- $query->where('top_depart_id', $top_depart_id)
|
|
|
- ->whereIn('depart_id', $depart_range)
|
|
|
- ->orWhere('top_depart_id',$top_depart)
|
|
|
+ $query->where(function ($q) use ($top_depart_id, $depart_range, $top_depart) {
|
|
|
+ $q->where(function ($q2) use ($top_depart_id, $depart_range) {
|
|
|
+ $q2->where('top_depart_id', $top_depart_id)
|
|
|
+ ->whereIn('depart_id', $depart_range);
|
|
|
+ })
|
|
|
+ ->orWhere('top_depart_id', $top_depart);
|
|
|
+ })
|
|
|
->whereNotIn('id', $id);
|
|
|
+ //某个分社全部 去掉不可见数
|
|
|
+// $query->where('top_depart_id', $top_depart_id)
|
|
|
+// ->whereIn('depart_id', $depart_range)
|
|
|
+// ->orWhere('top_depart_id',$top_depart)
|
|
|
+// ->whereNotIn('id', $id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -588,13 +610,34 @@ class UseScopeBaseModel extends Model
|
|
|
}
|
|
|
|
|
|
//某个分社全部 去掉不可见数
|
|
|
- $query->where('top_depart_id', $top_depart_id)
|
|
|
- ->when(! empty($check_search), function ($query) use ($check_search) {
|
|
|
- return $query->whereRaw($check_search);
|
|
|
- })
|
|
|
- ->whereIn('depart_id', $depart_range)
|
|
|
- ->whereNotIn('id', $id)
|
|
|
- ->OrWhereRaw($check_search2);
|
|
|
+// $query->where('top_depart_id', $top_depart_id)
|
|
|
+// ->when(! empty($check_search), function ($query) use ($check_search) {
|
|
|
+// return $query->whereRaw($check_search);
|
|
|
+// })
|
|
|
+// ->whereIn('depart_id', $depart_range)
|
|
|
+// ->whereNotIn('id', $id)
|
|
|
+// ->OrWhereRaw($check_search2);
|
|
|
+
|
|
|
+ $query->where(function ($q) use (
|
|
|
+ $top_depart_id,
|
|
|
+ $depart_range,
|
|
|
+ $id,
|
|
|
+ $check_search,
|
|
|
+ $top_depart,
|
|
|
+ $check_search2
|
|
|
+ ) {
|
|
|
+ // 主分社条件
|
|
|
+ $q->where('top_depart_id', $top_depart_id)
|
|
|
+ ->whereIn('depart_id', $depart_range)
|
|
|
+ ->whereNotIn('id', $id)
|
|
|
+ ->when(! empty($check_search), function ($q) use ($check_search) {
|
|
|
+ $q->whereRaw($check_search);
|
|
|
+ });
|
|
|
+
|
|
|
+ // OR 总社条件
|
|
|
+ $q->orWhereRaw($check_search2);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|