FilamentF
Filament3y ago
Veur

How to create a sub-resource

Hi, I'm trying to create a sub-resource for one of my resources.

The parent resource is WebsiteResource and the sub-resource is PageResource.

The WebsiteResource is accessible from /websites. I want the sub-resource to be accessible through /websites/1/pages (for the list of pages) and /websites/1/pages/1 (for the view of Page:1).

I tried to accomplish this with the code below in the sub-resource, but it's giving me a Illuminate\Routing\Exceptions\UrlGenerationException (missing parameter):

public static function getPages(): array
{
    return [
        'index' => Pages\ListPages::route('/{website}'),
        'view' => Pages\ViewPage::route('/{website}/{record}'),
    ];
}
Was this page helpful?