Home > Enterprise >  Laravel Filament Table Actions: url() not working
Laravel Filament Table Actions: url() not working

Time:11-22

I'm using Filament to create a table. I have the following two functions in my Livewire class. The getTableRecordUrlUsing() function works as expected.

The getTableActions() function spawns an error page saying "Missing required parameter for [Route: recipe.show] [URI: recipe/{id}] [Missing parameter: id]."


    protected function getTableActions()
    {
        return [
            Action::make('edit')
                ->url(fn (Recipe $r): string => route('recipe.show', ['id' => $r])),
        ];
    }

    protected function getTableRecordUrlUsing()
    {
        return function (Recipe $r) {
            return route('recipe.show', ['id' => $r]);
        };
    }


One function works. The other doesn't. I'm out of ideas.

CodePudding user response:

Do not change closure parameter names in filament, try to rename $r to $record :

protected function getTableActions()
{
    return [
        Action::make('edit')
            ->url(fn (Recipe $record): string => route('recipe.show', ['id' => $record])),
    ];
}

...
  • Related