Use scopes #18

Merged
nomadjimbob merged 39 commits from useScopes into main 2023-03-13 09:49:42 +00:00
Showing only changes of commit a9b480994a - Show all commits

View File

@@ -133,7 +133,7 @@ class Conductor {
$value = trim($value);
// Check if value has a prefix and remove it if it's a number
if (preg_match('/^([<>]=?)(\d+\.?\d*)$/', $value, $matches)) {
if (preg_match('/^([<>!=]=?)(\d+\.?\d*)$/', $value, $matches)) {
$prefix = $matches[1];
$value = $matches[2];
} else {
@@ -143,8 +143,11 @@ class Conductor {
// If the value starts with '=', exact match
if (strpos($value, '=') === 0) {
$query->where($field, '=', substr($value, 1));
} else if (strpos($value, '!=') === 0) {
$query->where($field, '<>', substr($value, 2));
} else if (strpos($value, '!') === 0) {
$query->where($field, 'NOT LIKE', '%'.substr($value, 1).'%');
} else {
// Otherwise, use LIKE with '%value%'
$query->where($field, 'LIKE', "%$value%");
}
@@ -163,6 +166,10 @@ class Conductor {
case '<=':
$query->where($field, '<=', $value);
break;
case '!=':
case '<>':
$query->where($field, '<>', $value);
break;
}
}
}