|
@@ -770,6 +770,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
$pro = $this->pro;
|
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
|
if (empty($term)) return '';
|
|
|
+
|
|
|
+ // if multiple words in query, check for all (max 2)
|
|
|
+ $term2 = '';
|
|
|
+ if(strpos($term, ' ') !== FALSE) {
|
|
|
+ $terms = explode(' ', $term);
|
|
|
+ $term = trim($terms[0]);
|
|
|
+ $term2 = trim($terms[1]);
|
|
|
+ }
|
|
|
+
|
|
|
$clientQuery= Client::whereNull('shadow_pro_id')
|
|
|
->where(function ($q) use ($term) {
|
|
|
$q->where('name_first', 'ILIKE', '%' . $term . '%')
|
|
@@ -778,6 +787,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
->orWhere('phone_home', 'ILIKE', '%' . $term . '%');
|
|
|
});
|
|
|
|
|
|
+ if(!empty($term2)) {
|
|
|
+ $clientQuery = $clientQuery->where(function ($q) use ($term2) {
|
|
|
+ $q->where('name_first', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('name_last', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('cell_number', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('phone_home', 'ILIKE', '%' . $term2 . '%');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
if(!($pro->pro_type === 'ADMIN' && $pro->can_see_any_client_via_search)) {
|
|
|
$clientQuery->where(function ($q) use ($pro) {
|
|
|
$q->whereIn('id', $pro->getMyClientIds(true))
|