F
Filament2mo ago
Sidem

livewire action

Hey, I would like to know how to pass an action to my Livewire component. I would like when someone clicks on any div in my foreach, the ViewAction is used Here is my code :
<div>
<div class="container mx-auto p-4">
<div class="flex flex-wrap justify-center gap-4">
@foreach ($distribs as $distrib)
<div class="flex-none w-60 p-4 bg-white shadow-md rounded distributor">
<img src="{{ asset($distrib->typeDistrib->image_path) }}" alt="image distributeur" class="w-full h-32 object-cover rounded mb-2">
<h2 class="text-xl font-bold">{{ $distrib->typeDistrib->title }}</h2>
</div>
@endforeach
</div>
</div>
</div>
<div>
<div class="container mx-auto p-4">
<div class="flex flex-wrap justify-center gap-4">
@foreach ($distribs as $distrib)
<div class="flex-none w-60 p-4 bg-white shadow-md rounded distributor">
<img src="{{ asset($distrib->typeDistrib->image_path) }}" alt="image distributeur" class="w-full h-32 object-cover rounded mb-2">
<h2 class="text-xl font-bold">{{ $distrib->typeDistrib->title }}</h2>
</div>
@endforeach
</div>
</div>
</div>
Thanks !
2 Replies
Krzysztof
Krzysztof2mo ago
I've added an infolist with a custom view (using view and viewData to pass props) and an entry has an action method so the whole entry is clickable You can also use repeater so you have only one component where you add your distribs
Sidem
Sidem2mo ago
do you have some references ?
Want results from more Discord servers?
Add your server