I have defied a generic input
component in Laravel like this:
//file: views/components/input.balde.php
<input @foreach ($attrs as $attr=>$val)
{{ $attr }} = "{{ $val }}"
@endforeach
>
And I would like to use it as follows in blade templates:
<x-input :attrs="{{ ['type'=>'text', 'placeholder'=>"Search.."] }}" ></x-input>
the thing is when I pass an array object like the example above it seems to break the view, however when I send a variable like this:
@php
$attributesArray = ['type'=>'text', 'placeholder'=>"Search.."];
@endphp
<x-input :attrs="$attributesArray" ></x-input>
Is there a way to pass the array as is without having to create a variable and sending it so that I don't add unnecessary @php directive?