@@ -280,22 +280,18 @@ protected function getValuesFromWhere(array $where) : string
280
280
}
281
281
282
282
if (is_array ((new Arr )->get ($ where , "values " ))) {
283
- return implode ("_ " , collect ($ where ["values " ])->flatten ()->toArray ());
283
+ $ values = collect ($ where ["values " ])->flatten ()->toArray ();
284
+ return implode ("_ " , $ this ->processEnums ($ values ));
284
285
}
285
286
286
287
if (is_array ((new Arr )->get ($ where , "value " ))) {
287
- return implode ("_ " , collect ($ where ["value " ])->flatten ()->toArray ());
288
+ $ values = collect ($ where ["value " ])->flatten ()->toArray ();
289
+ return implode ("_ " , $ this ->processEnums ($ values ));
288
290
}
289
291
290
292
$ value = (new Arr )->get ($ where , "value " , "" );
291
293
292
- if ($ value instanceof \BackedEnum) {
293
- return $ value ->value ;
294
- } elseif ($ value instanceof \UnitEnum) {
295
- return $ value ->name ;
296
- }
297
-
298
- return $ value ;
294
+ return $ this ->processEnum ($ value );
299
295
}
300
296
301
297
protected function getValuesFromBindings (array $ where , string $ values ) : string
@@ -396,4 +392,20 @@ protected function recursiveImplode(array $items, string $glue = ",") : string
396
392
397
393
return $ result ;
398
394
}
395
+
396
+ private function processEnum (\BackedEnum |\UnitEnum |string $ value ): string
397
+ {
398
+ if ($ value instanceof \BackedEnum) {
399
+ return $ value ->value ;
400
+ } elseif ($ value instanceof \UnitEnum) {
401
+ return $ value ->name ;
402
+ }
403
+
404
+ return $ value ;
405
+ }
406
+
407
+ private function processEnums (array $ values ): array
408
+ {
409
+ return array_map (fn ($ value ) => $ this ->processEnum ($ value ), $ values );
410
+ }
399
411
}
0 commit comments