Skip to content

Commit f72f6e3

Browse files
Return node value using getKey() method
1 parent 9ebf2fc commit f72f6e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/SelectTree.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ private function buildNode($result, $resultMap): array
142142
// Create a node with 'name' and 'value' attributes
143143
$node = [
144144
'name' => $result->{$this->getTitleAttribute()},
145-
'value' => $result->id,
146-
'disabled' => in_array($result->id, $this->getDisabledOptions()),
145+
'value' => $result->getKey(),
146+
'disabled' => in_array($result->getKey(), $this->getDisabledOptions()),
147147
];
148148

149149
// Check if the result has children
150-
if (isset($resultMap[$result->id])) {
150+
if (isset($resultMap[$result->getKey()])) {
151151
$children = collect();
152152
// Recursively build child nodes
153-
foreach ($resultMap[$result->id] as $child) {
153+
foreach ($resultMap[$result->getKey()] as $child) {
154154
$childNode = $this->buildNode($child, $resultMap);
155155
$children->push($childNode);
156156
}

0 commit comments

Comments
 (0)