I am trying to pass some parameters to a blade component from an array.
Here is how I pass them:
@php
$buttons = array(
array(
"type" => "button",
"content" => "Button 1",
"leadingIcon" => "plus",
"trailingIcon" => "plus"
),
array(
"type" => "button",
"content" => "Button 2",
"leadingIcon" => "plus",
"trailingIcon" => "plus"
),
array(
"type" => "button",
"content" => "Button 3",
"leadingIcon" => "plus",
"trailingIcon" => "plus"
),
array(
"type" => "button",
"content" => "Button 4",
"leadingIcon" => "plus",
"trailingIcon" => "plus"
),
);
@endphp
<x-buttons-group :buttons="$buttons" size="small" style="secondary" fullWidth="false"/>
Now, inside the <x-buttons-group> component I am trying to do a loop with <x-buttons-button> that needs a parameters I just passed with the array.
Here is a source code for the :
<div class="{!!$fullWidth!!} flex flex-row space-x-0 overflow-hidden rounded-lg border {!!$borderColor!!}">
<ul class="flex w-full flex-row space-x-0">
@foreach($buttons as $button)
<li class="children:border-0 children:rounded-none w-full border-r {!!$borderRightColor!!} last:border-r-0">
<x-buttons-button @foreach($button as $key => $value) :{!!$key!!}="{!!$value!!}" @endforeach />
</li>
@endforeach
</ul>
</div>
Now, the problem is that when I view the source of the page this is what I get:
<div class="flex w-auto flex-row space-x-0 overflow-hidden rounded-lg border border-gray-300">
<ul class="flex w-full flex-row space-x-0">
<li class="children:border-0 children:rounded-none w-full border-r border-r-gray-300 last:border-r-0">
<x-buttons-button :type="button" :content="Button 1" :leadingIcon="plus" :trailingIcon="plus" />
</li>
<li class="children:border-0 children:rounded-none w-full border-r border-r-gray-300 last:border-r-0">
<x-buttons-button :type="button" :content="Button 2" :leadingIcon="plus" :trailingIcon="plus" />
</li>
<li class="children:border-0 children:rounded-none w-full border-r border-r-gray-300 last:border-r-0">
<x-buttons-button :type="button" :content="Button 3" :leadingIcon="plus" :trailingIcon="plus" />
</li>
<li class="children:border-0 children:rounded-none w-full border-r border-r-gray-300 last:border-r-0">
<x-buttons-button :type="button" :content="Button 4" :leadingIcon="plus" :trailingIcon="plus" />
</li>
</ul>
</div>
So... Instead of the component being rendered, it passes a raw line of text like <x-buttons-button :type="button" :content="Button 4" :leadingIcon="plus" :trailingIcon="plus" />.
Any idea about how I can solve this?
@foreach(...)<x-buttons-button...>@endforeach?@foreachfor the component parameters. I already have another@foreachabove the<li>inside the<x-buttons-group>component source code.:button="$button"