@@ -38,31 +38,46 @@ public function apply(object $query, array|string $value, Context $context): voi
38
38
return ;
39
39
}
40
40
41
- [$ operator , $ resolved ] = $ this ->resolveOperator ($ value );
42
-
43
- switch ($ operator ) {
44
- case 'eq ' :
45
- case 'in ' :
46
- $ this ->applyEquals ($ query , $ resolved );
47
- break ;
48
-
49
- case 'ne ' :
50
- $ this ->applyNotEquals ($ query , $ resolved );
51
- break ;
52
-
53
- case 'lt ' :
54
- case 'lte ' :
55
- case 'gt ' :
56
- case 'gte ' :
57
- $ this ->applyComparison ($ query , $ operator , $ resolved );
58
- break ;
59
-
60
- case 'like ' :
61
- $ this ->applyLike ($ query , $ resolved );
62
- break ;
63
-
64
- default :
65
- throw new BadRequestException ("Unsupported operator: $ operator " );
41
+ if (is_string ($ value ) || array_is_list ($ value )) {
42
+ $ this ->applyEquals ($ query , $ value );
43
+ return ;
44
+ }
45
+
46
+ foreach ($ value as $ operator => $ v ) {
47
+ switch ($ operator ) {
48
+ case 'eq ' :
49
+ case 'in ' :
50
+ $ this ->applyEquals ($ query , $ v );
51
+ break ;
52
+
53
+ case 'ne ' :
54
+ case 'notin ' :
55
+ $ this ->applyNotEquals ($ query , $ v );
56
+ break ;
57
+
58
+ case 'lt ' :
59
+ case 'lte ' :
60
+ case 'gt ' :
61
+ case 'gte ' :
62
+ $ this ->applyComparison ($ query , $ operator , $ v );
63
+ break ;
64
+
65
+ case 'like ' :
66
+ $ this ->applyLike ($ query , $ v );
67
+ break ;
68
+
69
+ case 'notlike ' :
70
+ $ this ->applyNotLike ($ query , $ v );
71
+ break ;
72
+
73
+ case 'null ' :
74
+ case 'notnull ' :
75
+ $ this ->applyNull ($ query , $ operator === 'null ' ? (bool ) $ v : !$ v );
76
+ break ;
77
+
78
+ default :
79
+ throw new BadRequestException ("Unsupported operator: $ operator " );
80
+ }
66
81
}
67
82
}
68
83
@@ -107,6 +122,18 @@ private function applyLike(object $query, array|string $value): void
107
122
$ query ->where ($ this ->getColumn (), 'like ' , $ value );
108
123
}
109
124
125
+ private function applyNotLike (object $ query , array |string $ value ): void
126
+ {
127
+ $ value = $ this ->firstValue ($ value );
128
+
129
+ $ query ->where ($ this ->getColumn (), 'not like ' , $ value );
130
+ }
131
+
132
+ private function applyNull (object $ query , bool $ value ): void
133
+ {
134
+ $ query ->{$ value ? 'whereNull ' : 'whereNotNull ' }($ this ->getColumn ());
135
+ }
136
+
110
137
private function firstValue (array |string $ value ): mixed
111
138
{
112
139
if (is_array ($ value )) {
0 commit comments