@@ -183,19 +183,21 @@ private function buildTreeFromResults($results, $parent = null): Collection
183183
184184 private function buildNode ($ result , $ resultMap , $ disabledOptions , $ hiddenOptions ): array
185185 {
186+ $ key = $ result ->{$ this ->getCustomKey ()};
187+
186188 // Create a node with 'name' and 'value' attributes
187189 $ node = [
188190 'name ' => $ result ->{$ this ->getTitleAttribute ()},
189- 'value ' => $ result ->{ $ this -> getCustomKey ()} ,
190- 'disabled ' => in_array ($ result ->{ $ this -> getCustomKey ()} , $ disabledOptions ),
191- 'hidden ' => in_array ($ result ->{ $ this -> getCustomKey ()} , $ hiddenOptions ),
191+ 'value ' => $ key ,
192+ 'disabled ' => in_array ($ key , $ disabledOptions ),
193+ 'hidden ' => in_array ($ key , $ hiddenOptions ),
192194 ];
193195
194196 // Check if the result has children
195- if (isset ($ resultMap [$ result ->{ $ this -> getCustomKey ()} ])) {
197+ if (isset ($ resultMap [$ key ])) {
196198 $ children = collect ();
197199 // Recursively build child nodes
198- foreach ($ resultMap [$ result ->{ $ this -> getCustomKey ()} ] as $ child ) {
200+ foreach ($ resultMap [$ key ] as $ child ) {
199201 // don't add the hidden ones
200202 if (in_array ($ child ->{$ this ->getCustomKey ()}, $ hiddenOptions )) {
201203 continue ;
0 commit comments