I have a Blade Anonymous Component.
I want to pass an attribute to the components as object.
When I do this, the object converts to string
The component file:
@props(['object'])
{{ $object }}
The component call:
<x-component object="object variable" />
CodePudding user response:
Try like this, prepending a :
before the attribute name. Example:
welcome.blade.php
@php
$customer = (object)['name' => 'Kenny'];
@endphp
<x-customer-component :customer="$customer"/>
^
customer-component.blade.php
<div>
<p>Hey, my name is {{ $customer->name }}</p>
</div>