F
Filament2d ago
Liam

Parent resources with nav

I understand that a resource can have a parent resource set, but am trying to get some behaviour and not sure if it's easily possible after digging a bit. Let's say we have an article that belongs to a category. Current behaviour - Article belonging to the category list is routed at /categories/{category}/articles - Article belonging to the category is routed at /categories/{category}/articles/{article} What I want I want the above, but also the non-parent variations of the list route to work, including that being linked in the nav etc. - Article list is routed at /articles - Article list belonging to the category is routed at /categories/{category}/articles - Article belonging to the category is routed at /categories/{category}/articles/{article} Any pointers on how to get that working?
1 Reply
LeandroFerreira
I think you can follow this: Create a CategoryResource Create a Nested Resource: php artisan make:filament-resource Article --nested Create a Relation Page: php artisan make:filament-page ManageArticles --resource=CategoryResource --type=ManageRelatedRecords Register this page in CategoryResource getPages array:
public static function getPages(): array
{
return [
...
'articles' => ManageArticles::route('/{record}/articles')
];
}
public static function getPages(): array
{
return [
...
'articles' => ManageArticles::route('/{record}/articles')
];
}

Did you find this page helpful?