Skip to content

Commit 2768ca2

Browse files
committed
Fix opts and attr setter
1 parent e1e6da2 commit 2768ca2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Html/Editor/Fields/Field.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\Support\Arrayable;
7-
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
8-
use Illuminate\Database\Eloquent\Model;
97
use Illuminate\Database\Query\Builder as QueryBuilder;
108
use Illuminate\Support\Fluent;
119
use Illuminate\Support\Str;
@@ -323,7 +321,11 @@ public function compare(bool $value): static
323321
*/
324322
public function opts(array $value): static
325323
{
326-
$this->attributes['opts'] = $value;
324+
if (! isset($this->attributes['opts'])) {
325+
$this->attributes['opts'] = $value;
326+
} else {
327+
$this->attributes['opts'] = array_merge_recursive((array) $this->attributes['opts'], $value);
328+
}
327329

328330
return $this;
329331
}
@@ -338,8 +340,10 @@ public function opts(array $value): static
338340
*/
339341
public function attr(string $attribute, int|bool|string $value): static
340342
{
341-
// @phpstan-ignore-next-line
342-
$this->attributes['attr'][$attribute] = $value;
343+
$attributes = (array) $this->attributes['attr'];
344+
$attributes[$attribute] = $value;
345+
346+
$this->attributes['attr'] = $attributes;
343347

344348
return $this;
345349
}

0 commit comments

Comments
 (0)