Custom BulkAction
Hi guys, newbie here...
in a table i would like to pass the selected record to a controller and then perform some operations with the data.
Here is what i have When I click on the action button nothing happens
Thanks for the help!!
12 Replies
this doesn't execute any actions. To proceed, consider implementing a request or redirection to this route.
thanks @Leandro Ferreira, could you pls guide me to implement it ? again i'm pretty green..
url()
is a method that just generates a string.
You probably need something like return redirect(...)
I think you can use
redirect()->action([YourController::class, 'your_method']);
if you are using a controller
Please check the laravel docs: https://laravel.com/docs/11.x/responses#redirecting-controller-actionsLaravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
@pgferro here are two options to download PDF files, from our similar project - just not on BulkAction, but on a Table Action, but it should be similar for your case:
Option 1: Action with Download
Option 2: Redirect to Controller that would do the work
Full example: https://laraveldaily.com/post/filament-export-record-to-pdf-two-ways
(keep in mind this was written for Filament 2, so double-check the syntax)
Laravel Daily
Filament: Export Record to PDF - Two Ways
thanks @PovilasKorop ! Of course I saw that article 😃 My struggle is to undertsand how to pass the collection instead of a sigle record to the controller. I tried everything I could think without success...
@PovilasKorop i have this.
and it doesnt work, nothin happens on the click of the action
Because return view doesn't actually return anything - it should be either downloading something or going to another URL. Check my examples above - they don't return view
return response not a view. https://livewire.laravel.com/docs/downloads
Laravel
File Downloads | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Update: we published a snippet on our examples page, but to avoid being too "promotional", here's the main code: