Skip to content

Commit 00894b8

Browse files
[10.x] Make ComponentAttributeBag JsonSerializable (#48338)
* [10.x] Make ComponentAttributeBag JsonSerializable * Fix return type * Explicit mixed return type * Update ComponentAttributeBag.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 3caca4c commit 00894b8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Illuminate/View/ComponentAttributeBag.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
use Illuminate\Support\Traits\Conditionable;
1212
use Illuminate\Support\Traits\Macroable;
1313
use IteratorAggregate;
14+
use JsonSerializable;
1415
use Traversable;
1516

16-
class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate
17+
class ComponentAttributeBag implements ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable
1718
{
1819
use Conditionable, Macroable;
1920

@@ -455,6 +456,16 @@ public function getIterator(): Traversable
455456
return new ArrayIterator($this->attributes);
456457
}
457458

459+
/**
460+
* Convert the object into a JSON serializable form.
461+
*
462+
* @return mixed
463+
*/
464+
public function jsonSerialize(): mixed
465+
{
466+
return $this->attributes;
467+
}
468+
458469
/**
459470
* Implode the attributes into a single HTML ready string.
460471
*

0 commit comments

Comments
 (0)