In a Laravel Blade component, I want to pass through arbitrary attributes into another custom component

54 Views Asked by At

In a Laravel blade component file, we can pass through attributes given to us into an HTML tag like this:

<div {{ $attributes->merge(['class' => 'alert alert-'.$type]) }}>
    {{ $message }}
</div>

And we can call another custom component like this:

<x-alert message="Look out!" :title="$title" />

However, how can I pass through all attributes given to us (including "class" and "onclick", etc) into a component? I would like to do this, but it complains at me.

<x-alert message="Look out!" {{ $attributes->merge(['title' => 'Hey!']) }} />

Thanks!

0

There are 0 best solutions below