|
@@ -1804,12 +1804,29 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
if (empty($term)) return '';
|
|
if (empty($term)) return '';
|
|
$term = strtolower($term);
|
|
$term = strtolower($term);
|
|
|
|
+
|
|
|
|
+ // 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]);
|
|
|
|
+ }
|
|
|
|
+
|
|
$pros = Pro::where(function ($q) use ($term) {
|
|
$pros = Pro::where(function ($q) use ($term) {
|
|
$q->orWhereRaw('LOWER(name_first::text) LIKE ?', ['%' . $term . '%'])
|
|
$q->orWhereRaw('LOWER(name_first::text) LIKE ?', ['%' . $term . '%'])
|
|
->orWhereRaw('LOWER(name_last::text) LIKE ?', ['%' . $term . '%'])
|
|
->orWhereRaw('LOWER(name_last::text) LIKE ?', ['%' . $term . '%'])
|
|
->orWhereRaw('cell_number LIKE ?', ['%' . $term . '%']);
|
|
->orWhereRaw('cell_number LIKE ?', ['%' . $term . '%']);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ if(!empty($term2)) {
|
|
|
|
+ $pros = $pros->where(function ($q) use ($term2) {
|
|
|
|
+ $q->orWhereRaw('LOWER(name_first::text) LIKE ?', ['%' . $term2 . '%'])
|
|
|
|
+ ->orWhereRaw('LOWER(name_last::text) LIKE ?', ['%' . $term2 . '%'])
|
|
|
|
+ ->orWhereRaw('cell_number LIKE ?', ['%' . $term2 . '%']);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
$type = $request->input('type') ? trim($request->input('type')) : '';
|
|
$type = $request->input('type') ? trim($request->input('type')) : '';
|
|
if(!!$type) {
|
|
if(!!$type) {
|
|
switch(strtolower($type)) {
|
|
switch(strtolower($type)) {
|