diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 1d0a790b4256..812b9829551a 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -11,9 +11,10 @@ use Illuminate\Support\Traits\Conditionable; use Illuminate\Support\Traits\Macroable; use IteratorAggregate; +use JsonSerializable; use Traversable; -class ComponentAttributeBag implements ArrayAccess, Htmlable, IteratorAggregate +class ComponentAttributeBag implements ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable { use Conditionable, Macroable; @@ -455,6 +456,16 @@ public function getIterator(): Traversable return new ArrayIterator($this->attributes); } + /** + * Convert the object into a JSON serializable form. + * + * @return mixed + */ + public function jsonSerialize(): mixed + { + return $this->attributes; + } + /** * Implode the attributes into a single HTML ready string. *