@@ -280,22 +280,18 @@ protected function getValuesFromWhere(array $where) : string
280280 }
281281
282282 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 ));
284285 }
285286
286287 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 ));
288290 }
289291
290292 $ value = (new Arr )->get ($ where , "value " , "" );
291293
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 );
299295 }
300296
301297 protected function getValuesFromBindings (array $ where , string $ values ) : string
@@ -396,4 +392,20 @@ protected function recursiveImplode(array $items, string $glue = ",") : string
396392
397393 return $ result ;
398394 }
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+ }
399411}
0 commit comments