Opening URLs from notification actions thows error ==> Route [pagos.index] not defined.

Hello. I have an action in a notification which I want to take the user to a resource index page. The resource is called pagos. I have used the official documentation in: https://filamentphp.com/docs/3.x/notifications/sending-notifications#opening-urls-from-notification-actions and only changed route('posts.show') for route('pagos.index') And it thows the same error. I have tried with 'admin.pagos.index', 'pagos', 'admin.pagos', tried in singular pago but I cannot achieve it. Any ideas, please: My code:
Action::make('ir a contabilidad')
->button()
->url(route('pagos.index'), shouldOpenInNewTab: true)
Action::make('ir a contabilidad')
->button()
->url(route('pagos.index'), shouldOpenInNewTab: true)
Solution:
I got a mistake and now I have solved it. My Notification message with Action is included inside another Action. I had this: use Filament\Tables\Actions\Action; Which is Ok for the main Action, but for the Action in the notification I must use:...
Jump to solution
7 Replies
Mansoor Khan
Mansoor Khan4mo ago
Hey, By default Filament routes are named as filament.admin.resources.{resourceName}.index. If you have not customised it, try to change it to: filament.admin.resources.pagos.index and see if that works for you.
Nox
Nox4mo ago
php artisan route::list or ressource::getUrl('index') might just be ressource::url('index')
Matthew
Matthew4mo ago
pagos is not a word its pages Also, I dont recommend redirecting that way. This is better:
$this->getResource()::getUrl('index')
$this->getResource()::getUrl('index')
Solution
Albert Lens
Albert Lens4mo ago
I got a mistake and now I have solved it. My Notification message with Action is included inside another Action. I had this: use Filament\Tables\Actions\Action; Which is Ok for the main Action, but for the Action in the notification I must use: \Filament\Notifications\Actions\Action So, now everything is working fine with this code:
Notification::make()
->title('Traspaso realizado correctamente')
->body('Ahora puede exportar el archivo Excel para su traspaso a contabilidad.')
->duration(5000)
->icon('heroicon-o-arrows-right-left')
->success()
->color('amber')
->actions([
\Filament\Notifications\Actions\Action::make('Ir a Contabilidad') //NOTE THIS LINE WITH not just Action::make but \Filament.....
->button()
->url('/diarios')
->color('amber')
])
->send();
Notification::make()
->title('Traspaso realizado correctamente')
->body('Ahora puede exportar el archivo Excel para su traspaso a contabilidad.')
->duration(5000)
->icon('heroicon-o-arrows-right-left')
->success()
->color('amber')
->actions([
\Filament\Notifications\Actions\Action::make('Ir a Contabilidad') //NOTE THIS LINE WITH not just Action::make but \Filament.....
->button()
->url('/diarios')
->color('amber')
])
->send();
Tks.
Albert Lens
Albert Lens4mo ago
Thank you. Pagos is PAYMENTS in Spanish and it is a resource.
Matthew
Matthew4mo ago
ohhh 🤣 mb didnt know xd
Albert Lens
Albert Lens4mo ago
Thank you everybody for your help. We must be very careful using shortcuts like Action::make instead of \Filament\Notifications\Actions\Action or \Filament\Tables\Actions\Action. To be user it is better to use the whole route with \Filament...