@@ -37,8 +37,6 @@ class SelectTree extends Field implements HasAffixActions
37
37
38
38
protected bool $ independent = true ;
39
39
40
- protected string $ customKey = null ;
41
-
42
40
protected string $ titleAttribute ;
43
41
44
42
protected string $ parentAttribute ;
@@ -113,7 +111,7 @@ protected function setUp(): void
113
111
114
112
$ form ->model ($ record )->saveRelationships ();
115
113
116
- return $ record ->{ $ this -> getCustomKey ()} ;
114
+ return $ record ->getKey () ;
117
115
});
118
116
119
117
$ this ->suffixActions ([
@@ -186,18 +184,18 @@ private function buildNode($result, $resultMap, $disabledOptions, $hiddenOptions
186
184
// Create a node with 'name' and 'value' attributes
187
185
$ node = [
188
186
'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 ),
187
+ 'value ' => $ result ->getKey () ,
188
+ 'disabled ' => in_array ($ result ->getKey () , $ disabledOptions ),
189
+ 'hidden ' => in_array ($ result ->getKey () , $ hiddenOptions ),
192
190
];
193
191
194
192
// Check if the result has children
195
- if (isset ($ resultMap [$ result ->{ $ this -> getCustomKey ()} ])) {
193
+ if (isset ($ resultMap [$ result ->getKey () ])) {
196
194
$ children = collect ();
197
195
// Recursively build child nodes
198
- foreach ($ resultMap [$ result ->{ $ this -> getCustomKey ()} ] as $ child ) {
196
+ foreach ($ resultMap [$ result ->getKey () ] as $ child ) {
199
197
// don't add the hidden ones
200
- if (in_array ($ child ->{ $ this -> getCustomKey ()} , $ hiddenOptions )) {
198
+ if (in_array ($ child ->getKey () , $ hiddenOptions )) {
201
199
continue ;
202
200
}
203
201
$ childNode = $ this ->buildNode ($ child , $ resultMap , $ disabledOptions , $ hiddenOptions );
@@ -303,13 +301,6 @@ public function independent(bool $independent = true): static
303
301
return $ this ;
304
302
}
305
303
306
- public function withKey (string $ customKey = 'id ' ): static
307
- {
308
- $ this ->customKey = $ customKey ;
309
-
310
- return $ this ;
311
- }
312
-
313
304
public function disabledOptions (Closure |array $ disabledOptions ): static
314
305
{
315
306
$ this ->disabledOptions = $ disabledOptions ;
@@ -358,11 +349,6 @@ public function getIndependent(): bool
358
349
return $ this ->evaluate ($ this ->independent );
359
350
}
360
351
361
- public function getCustomKey (): string
362
- {
363
- return $ this ->customKey ? $ this ->evaluate ($ this ->customKey ) : $ this ->getKey ();
364
- }
365
-
366
352
public function getWithCount (): bool
367
353
{
368
354
return $ this ->evaluate ($ this ->withCount );
0 commit comments