Skip to content

Commit a3b7467

Browse files
committed
add append option
1 parent 5ec4a6f commit a3b7467

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/SelectTree.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class SelectTree extends Field implements HasAffixActions
8888

8989
protected Closure|array|null $prepend = null;
9090

91+
protected Closure|array|null $append = null;
92+
9193
protected Closure|string|null $treeKey = 'treeKey';
9294

9395
protected function setUp(): void
@@ -316,6 +318,19 @@ public function prepend(Closure|array|null $prepend = null): static
316318
return $this;
317319
}
318320

321+
public function append(Closure|array|null $append = null): static
322+
{
323+
$this->append = $this->evaluate($append);
324+
325+
if (is_array($this->append) && isset($this->append['name'], $this->append['value'])) {
326+
$this->append['value'] = (string) $this->append['value'];
327+
} else {
328+
throw new \InvalidArgumentException('The provided append value must be an array with "name" and "value" keys.');
329+
}
330+
331+
return $this;
332+
}
333+
319334
public function getRelationship(): BelongsToMany|BelongsTo
320335
{
321336
return $this->getModelInstance()->{$this->evaluate($this->relationship)}();

0 commit comments

Comments
 (0)