Im using to Laravel blade’s component to make a dynamic table, in which user can pass in header, and corresponding rows. I wanna use this component to display many tables (permissions, reviews, etc…). I use it in my view like this
<x-admin.data-table :items="$review" route="admin/users">
<x-slot:header>
<th>Name</th>
<th>Description</th>
</x-slot>
<x-slot:row :item="$item">
<td>{{$item->name}}</td>
<td>{{$item->description}}</td>
</x-slot:row>
</x-admin.data-table>
The row slot is display in data-table.blade.php
like this
<tbody>
@foreach ($items as $item)
<tr>
{{ $row(['item' => $item]) }}
</tr>
@endforeach
</tbody>
This part
<x-slot:row :item="$item">
<td>{{$item->name}}</td>
<td>{{$item->description}}</td>
</x-slot:row>
this is where people want to reuse this component, can pass their own attribute, i.e <td>{{$item->content}}</td>
.
But what i get is Undefined variable $item
. I tried using {{ $row->with(['item' => $item]) }}
too, but still a no. How should I pass the columns to my slot then?