Skip to content

Commit 7c1be94

Browse files
committed
feat: let getTree() append and prepend values to static getTreeUsing array
1 parent 7c0d765 commit 7c1be94

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/SelectTree.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,15 +550,11 @@ public function getTreeUsing(Closure|array $value): static
550550
return $this;
551551
}
552552

553-
public function getTree(): Collection|array
553+
public function getTree(): Collection
554554
{
555-
if ($this->getTreeUsing) {
556-
return $this->evaluate($this->getTreeUsing);
557-
}
558-
559-
return $this->evaluate($this->buildTree()
555+
return Collection::wrap($this->evaluate($this->getTreeUsing)) ?? $this->buildTree()
560556
->when($this->prepend, fn (Collection $tree) => $tree->prepend($this->evaluate($this->prepend)))
561-
->when($this->append, fn (Collection $tree) => $tree->push($this->evaluate($this->append)))
557+
->when($this->append, fn (Collection $tree) => $tree->push($this->evaluate($this->append))
562558
);
563559
}
564560

0 commit comments

Comments
 (0)