Nested resources
This would be amazing.
Perhaps we could add a $parentResourceClass to the Resource objects and change the routing accordingly.
I am guessing this should only work with belongsTo relations.
Then make the parent available via the getParent() method and $parent property just like we can access the getRecord() and $record.
@falko100 I don't think we should support only the BelongsTo relationship. I'm de suggester of this feature and I don't think this should work "automagically" behind the scenes. I think we need to let users customize their parents using some trait or extending a ParentResource or ChildrenResource
I have a couple of use cases for this, gonna give some examples to help the team with the brainstorming of this feature:
Blogging
- User can create many blogs
/app/blogs - User can list blog posts
/app/blogs/{1}/posts - User can view blog post
/app/blogs/{1}/posts/{1} - User can list blog categories, but categories may belong to multiple blogs
/app/blogs/1/categories - User can list posts inside a category
/app/blogs/1/categories/1/posts
Calendar events
- User can create many calendars
/app/{calendars} - User can list calendar events
/app/calendars/{1}/events - User can view calendar event
/app/calendars/{1}/events/{1}
GitHub-like interface
- User can create an org
/{filamentphp} - User can create repositories inside orgs
/{filamentphp}/repositories/{filament} - User can list issues of a repository
/{filamentphp}/repositories/{filament}/issues - User can view files of a PR
/{filamentphp}/repositories/{filament}/pulls/{1}/files/{tables.blade.php}
I've already had this setup working with filament, but the only issue is breadcrumbs and route parameter resolving everything else is already working.
Basically, we only need to inform a resource of its parent (for route param resolving) and add /{parentSlug}/{parentRecord} to the children's resource URLs.
@saade I get your point. I don't see a particular use-case for having the ManyToMany nested (the categories-posts relation) as they are not hierarchical, but if the team thinks that it will work, I am all for it.
I wouldn't mind helping out on the PR.
no plz dont depending
Great to see this on the roadmap. I have the need for this in many of the applications I build.
Looking forward to where this goes! 🚀
I have sub-resources working with a reusable trait - coupled with the new SubNavigation Feature - I think it's a good start. Probably needs a few changes, but if anyone is looking for ideas: https://gist.github.com/nicko170/7348812b1240f2eb196fd22ece1fe977
https://laraveldaily.com/post/filament-v3-nested-resources-trait-pages
@krekas nice work! Just made some small refactors to make the code a bit cleaner =)
https://github.com/LaravelDaily/filament-nested-resources/pull/1
@saade not my work. Just sharing :)
There is this package also https://github.com/Sevendays-Digital/filament-nested-resources, but I don't know if it works with V3 or with spatie-translatable