Skip to content

Commit ce48160

Browse files
committed
merged
1 parent b026bf6 commit ce48160

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/SelectTree.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,13 @@ public function multiple(Closure|bool $multiple = true): static
301301

302302
public function prepend(Closure|array|null $prepend = null): static
303303
{
304-
$this->prepend = $prepend;
304+
$this->prepend = $this->evaluate($prepend);
305+
306+
if (is_array($this->prepend) && isset($this->prepend['name'], $this->prepend['value'])) {
307+
$this->prepend['value'] = (string) $this->prepend['value'];
308+
} else {
309+
throw new \InvalidArgumentException('The provided prepend value must be an array with "name" and "value" keys.');
310+
}
305311

306312
return $this;
307313
}
@@ -441,9 +447,11 @@ public function getIndependent(): bool
441447
return $this->evaluate($this->independent);
442448
}
443449

444-
public function getCustomKey($record)
450+
public function getCustomKey($record): string
445451
{
446-
return is_null($this->customKey) ? $record->getKey() : $record->{$this->customKey};
452+
$key = is_null($this->customKey) ? $record->getKey() : $record->{$this->customKey};
453+
454+
return (string) $key;
447455
}
448456

449457
public function getWithCount(): bool

0 commit comments

Comments
 (0)