Duplicate route message error in laravel filamentphp

In an environment with Laravel 10 and filamentphp 3 I want to create and display an invoice in a new tab. I have the following route in web.php:
Route::prefix('generatePdf')->name('generatePdf.')
->group(function () {
Route::controller(PdfController::class)->group(function () {
Route::get('/{record}/invoice/printTenantInvoice', 'printTenantInvoice')->name('invoice.print'); // Incident Reports
});
});
Route::prefix('generatePdf')->name('generatePdf.')
->group(function () {
Route::controller(PdfController::class)->group(function () {
Route::get('/{record}/invoice/printTenantInvoice', 'printTenantInvoice')->name('invoice.print'); // Incident Reports
});
});
which is invoked by the action in filamentphp table:
Action::make(__('Print'))
->icon('heroicon-o-printer')
->url(fn (Invoices $record): string => route('generatePdf.invoice.print', ['record' => $record]))
->openUrlInNewTab(),
Action::make(__('Print'))
->icon('heroicon-o-printer')
->url(fn (Invoices $record): string => route('generatePdf.invoice.print', ['record' => $record]))
->openUrlInNewTab(),
but when optimizing the cache with "php artisan optimize" it gives me the following error:
Unable to prepare route [generate-pdf/{record}/invoice/printTenantInvoice] for serialization. Another route has already been assigned name [generate-pdf.invoice.print].
Unable to prepare route [generate-pdf/{record}/invoice/printTenantInvoice] for serialization. Another route has already been assigned name [generate-pdf.invoice.print].
How do I eliminate the error? I have tried many ways to avoid the error but I ran out of ideas. I was hoping it could optimize the cache but it continues to throw the error even though the file is generated correctly.
1 Reply
Dennis Koch
Dennis Koch7mo ago
You are sure you didn’t add a route with the same name? The error comes from Laravel not Filament.