© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Jon Mason

Modifying slug in resource class

I have a resource class that's related to a model, and I want to have a url like
locations/{location}/vendors/{vendor} to edit the vendors related to the location. However, I don't want to use a RelationManager, I just want to have a separate page where a user can manage the records.

I've modified my VendorResource class to attach the slug, and I can link this, but 1, I'm getting a 
locations/{location}/vendors/{vendor} to edit the vendors related to the location. However, I don't want to use a RelationManager, I just want to have a separate page where a user can manage the records.

I've modified my VendorResource class to attach the slug, and I can link this, but 1, I'm getting a 
Missing required parameter` error for the location parameter, and 2) how do I ensure that when I load the resource page, it's only pulling the vendors associated with the location.

class VendorResource extends Resource
{
    protected static ?string $model = Vendor::class;

    protected static bool $shouldRegisterNavigation = false;

    protected static ?string $slug = 'locations/{location}/vendors'

...
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListVendors::route('/'),
            'create' => Pages\CreateVendor::route('/create'),
            'edit' => Pages\EditVendor::route('/{record}/edit'),
        ];
    }
}
class VendorResource extends Resource
{
    protected static ?string $model = Vendor::class;

    protected static bool $shouldRegisterNavigation = false;

    protected static ?string $slug = 'locations/{location}/vendors'

...
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListVendors::route('/'),
            'create' => Pages\CreateVendor::route('/create'),
            'edit' => Pages\EditVendor::route('/{record}/edit'),
        ];
    }
}


Here's where I'm linking to the resource class:

 $items[] = NavigationItem::make('Vendors')
                ->icon('heroicon-o-truck')
                ->group($selectedLocation->name)
                ->isActiveWhen(fn (): bool => request()->routeIs('filament.app.resources.vendors.*'))
                ->url(VendorResource::getUrl('index', ['location' => $selectedLocation->id]));
 $items[] = NavigationItem::make('Vendors')
                ->icon('heroicon-o-truck')
                ->group($selectedLocation->name)
                ->isActiveWhen(fn (): bool => request()->routeIs('filament.app.resources.vendors.*'))
                ->url(VendorResource::getUrl('index', ['location' => $selectedLocation->id]));
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

Custom pages in class resource
FilamentFFilament / ❓┊help
17mo ago
Get resource in Action class
FilamentFFilament / ❓┊help
2y ago
Pros/Cons in using Resource class vs *Record classes
FilamentFFilament / ❓┊help
17mo ago
two different enum class in one resource
FilamentFFilament / ❓┊help
3y ago