@@ -233,7 +233,7 @@ private function buildNode($result, $resultMap, $disabledOptions, $hiddenOptions
233233 $ node = [
234234 'name ' => $ result ->{$ this ->getTitleAttribute ()},
235235 'value ' => $ key ,
236- 'parent ' => $ result ->{$ this ->getParentAttribute ()},
236+ 'parent ' => ( string ) $ result ->{$ this ->getParentAttribute ()},
237237 'disabled ' => in_array ($ key , $ disabledOptions ),
238238 'hidden ' => in_array ($ key , $ hiddenOptions ),
239239 ];
@@ -305,7 +305,13 @@ public function multiple(Closure|bool $multiple = true): static
305305
306306 public function prepend (Closure |array |null $ prepend = null ): static
307307 {
308- $ this ->prepend = $ prepend ;
308+ $ this ->prepend = $ this ->evaluate ($ prepend );
309+
310+ if (is_array ($ this ->prepend ) && isset ($ this ->prepend ['name ' ], $ this ->prepend ['value ' ])) {
311+ $ this ->prepend ['value ' ] = (string ) $ this ->prepend ['value ' ];
312+ } else {
313+ throw new \InvalidArgumentException ('The provided prepend value must be an array with "name" and "value" keys. ' );
314+ }
309315
310316 return $ this ;
311317 }
@@ -445,9 +451,11 @@ public function getIndependent(): bool
445451 return $ this ->evaluate ($ this ->independent );
446452 }
447453
448- public function getCustomKey ($ record )
454+ public function getCustomKey ($ record ): string
449455 {
450- return is_null ($ this ->customKey ) ? $ record ->getKey () : $ record ->{$ this ->customKey };
456+ $ key = is_null ($ this ->customKey ) ? $ record ->getKey () : $ record ->{$ this ->customKey };
457+
458+ return (string ) $ key ;
451459 }
452460
453461 public function getWithCount (): bool
0 commit comments