© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
1 reply
Adysone

Custom resource route with extra parameters

Hello,

I'd like to make this work:

class ContactResource extends Resource
{
    // (...)

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListContacts::route('/{contact_type}/'),
            'create' => Pages\CreateContact::route('/{contact_type}/create'),
            'edit' => Pages\EditContact::route('/{contact_type}/{record}/edit'),
        ];
    }

    // (...)
}
class ContactResource extends Resource
{
    // (...)

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListContacts::route('/{contact_type}/'),
            'create' => Pages\CreateContact::route('/{contact_type}/create'),
            'edit' => Pages\EditContact::route('/{contact_type}/{record}/edit'),
        ];
    }

    // (...)
}


I'd like to preserve the "contact_type" parameter when I edit, create or delete a record in the Contact table.

In the navigation menu, I generate links dynamically according to "Contact types" created by the superadmin, so I came with this in the AdminPanelProvider (with a question in it):

        $thirdPartyContactTypeNavigationItems = ContactType::orderBy('label')
            ->get()
            ->map(function (ContactType $contactType): NavigationItem {
                return NavigationItem::make($contactType->label)
                    ->icon('heroicon-o-users')
                    ->group(__('ThirdParty/main.third_party'))
                    ->isActiveWhen(function () use ($contactType): bool {
                        // How can I get the current value of contact_type?
                    })
                    ->url(fn (): string => ContactResource::getUrl(
                        parameters: ['contact_type' => $contactType->code]
                    ));
            })
            ->all();

        return $panel
            // (...)
            ->navigationItems($thirdPartyContactTypeNavigationItems);
        $thirdPartyContactTypeNavigationItems = ContactType::orderBy('label')
            ->get()
            ->map(function (ContactType $contactType): NavigationItem {
                return NavigationItem::make($contactType->label)
                    ->icon('heroicon-o-users')
                    ->group(__('ThirdParty/main.third_party'))
                    ->isActiveWhen(function () use ($contactType): bool {
                        // How can I get the current value of contact_type?
                    })
                    ->url(fn (): string => ContactResource::getUrl(
                        parameters: ['contact_type' => $contactType->code]
                    ));
            })
            ->all();

        return $panel
            // (...)
            ->navigationItems($thirdPartyContactTypeNavigationItems);


Thanks!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to have Resource with custom route parameters?
FilamentFFilament / ❓┊help
3y ago
Custom route with path parameters for custom page
FilamentFFilament / ❓┊help
3y ago
Extra route parameter for a resource
FilamentFFilament / ❓┊help
2y ago
Custom Page with URL parameters
FilamentFFilament / ❓┊help
3y ago