I have a table full of records of ModelA.
In this table I am trying to make a bulkaction.
This bulkaction should redirect to a route provided in the web.php in a new tab.
However there are some conditions.
First and foremost I need to have actual records selected, the rest don’t really matter for the issue.
BulkAction::make('generate_report')
->label('Blabla name and stuff')
->requiresConfirmation()
//->url('urlthatworks') //this works 100% as we want.
->url(function ($records) {
$route = '';
if ($records) {
$route = route('name_in_webphp', ['param1' => 'somevalue', 'param2' => 'someothervalue'])
//dd($route); //this dd gets hit when uncommented and print the url that works 100% if we hardcode it like above.
}
return $route;
})
->openUrlInNewTab()
->icon('heroicon-o-eye'),
This is the bulkaction we wish to use, however it doesnt do anything when we select a row and press the bulkactionbutton.
For a complete picture the web.php has the route defined:
Route::get('route/{param1}/{param2}', [Destination::class, 'destinationfunction'])->name('name_in_webphp');
And the Destination class has this destinationfunction function which just has a dd to print param1 and param2.
My question is as follows:
Why doesnt the closure redirects us to the new tab and route while a hardcoded value of the route works just fine?
Did I do something wrong or is there an issue in filament?
Is there some workaround?