@@ -113,7 +113,7 @@ protected function setUp(): void
113
113
114
114
$ form ->model ($ record )->saveRelationships ();
115
115
116
- return $ record ->{ $ this ->getCustomKey ()} ;
116
+ return $ this ->getCustomKey ($ record ) ;
117
117
});
118
118
119
119
$ this ->suffixActions ([
@@ -183,8 +183,8 @@ private function buildTreeFromResults($results, $parent = null): Collection
183
183
184
184
private function buildNode ($ result , $ resultMap , $ disabledOptions , $ hiddenOptions ): array
185
185
{
186
- $ key = $ result ->{ $ this ->getCustomKey ()} ;
187
-
186
+ $ key = $ this ->getCustomKey ($ result ) ;
187
+
188
188
// Create a node with 'name' and 'value' attributes
189
189
$ node = [
190
190
'name ' => $ result ->{$ this ->getTitleAttribute ()},
@@ -200,7 +200,7 @@ private function buildNode($result, $resultMap, $disabledOptions, $hiddenOptions
200
200
// Recursively build child nodes
201
201
foreach ($ resultMap [$ key ] as $ child ) {
202
202
// don't add the hidden ones
203
- if (in_array ($ child ->{ $ this ->getCustomKey ()} , $ hiddenOptions )) {
203
+ if (in_array ($ this ->getCustomKey ($ child ) , $ hiddenOptions )) {
204
204
continue ;
205
205
}
206
206
$ childNode = $ this ->buildNode ($ child , $ resultMap , $ disabledOptions , $ hiddenOptions );
@@ -306,7 +306,7 @@ public function independent(bool $independent = true): static
306
306
return $ this ;
307
307
}
308
308
309
- public function withKey (string $ customKey = ' id ' ): static
309
+ public function withKey (string $ customKey ): static
310
310
{
311
311
$ this ->customKey = $ customKey ;
312
312
@@ -360,10 +360,10 @@ public function getIndependent(): bool
360
360
{
361
361
return $ this ->evaluate ($ this ->independent );
362
362
}
363
-
364
- public function getCustomKey (): string
363
+
364
+ public function getCustomKey ($ record )
365
365
{
366
- return is_null ($ this ->customKey ) ? $ this ->getKey () : $ this -> evaluate ( $ this ->customKey ) ;
366
+ return is_null ($ this ->customKey ) ? $ record ->getKey () : $ record ->{ $ this ->customKey } ;
367
367
}
368
368
369
369
public function getWithCount (): bool
0 commit comments