Route [pdfa] not defined url(fn(Applicant $record): string => route('pdfa', $record))

In short words: How do i have to create a link from an Action in a Table to a new created page (all in Admin Panel)? The new created page url already works! But i cant get the link from the action get working. And i need the record id in the new page. Details: In ApplicantResource.php i have created in the table:
->actions([
Action::make('pdfa')
->label('pdfa')
->url(fn(Applicant $record): string => route('pdfa', $record)),
->actions([
Action::make('pdfa')
->label('pdfa')
->url(fn(Applicant $record): string => route('pdfa', $record)),
And:
public static function getPages(): array
{
return [
'pdfa' => Pages\PdfApplicant::route('/{record}/pdfa'),
];
}
public static function getPages(): array
{
return [
'pdfa' => Pages\PdfApplicant::route('/{record}/pdfa'),
];
}
In app/Filament/Resources/ApplicantResource/Pages/PdfApplicant.php i have:
lass PdfApplicant extends Page
{
protected static string $resource = ApplicantResource::class;
protected static string $view = 'filament.resources.applicant-resource.pages.pdf-applicant';
}
lass PdfApplicant extends Page
{
protected static string $resource = ApplicantResource::class;
protected static string $view = 'filament.resources.applicant-resource.pages.pdf-applicant';
}
What do i miss? I get the error Route [pdfa] not defined. ☹️
3 Replies
ZedoX
ZedoX2y ago
ApplicantResource::getUrl('pdfa')
Dan Harrin
Dan Harrin2y ago
try ResourceName::getUrl('pdfa', ['record' => $record]) anywhere it will generate the route similar to route()
Falk Maria Zeitsprung
@z3d0x and @Dan Harrin 🤪 Thank you very much It works now so far with:
->url(ApplicantResource::getUrl('pdfa', ['record' => 60])),
->url(ApplicantResource::getUrl('pdfa', ['record' => 60])),
BUT how can i replace the 60 please with the id variable. $record is throwing the error: ErrorException PHP 8.1.15 10.3.3 Undefined variable $record @z3d0x @Dan Harrin Thank you very much!! I resolved it now with your help! The correct way seems to be: php
->url(fn(Applicant $record): string => ApplicantResource::getUrl('pdfa', ['record' => $record]))
->url(fn(Applicant $record): string => ApplicantResource::getUrl('pdfa', ['record' => $record]))
`
Want results from more Discord servers?
Add your server