Skip to content

Commit 247b00a

Browse files
Merge pull request #201 from gp-lnuff/4.x
Add append() and prepend() support for getTreeUsing()
2 parents 90bf491 + 14a2820 commit 247b00a

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/SelectTree.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +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)))
562-
);
557+
->when($this->append, fn (Collection $tree) => $tree->push($this->evaluate($this->append)));
563558
}
564559

565560
public function getResults(): Collection|LazyCollection|array|null

0 commit comments

Comments
 (0)