Download the PHP package guava/filament-nested-resources without Composer
On this page you can find all versions of the php package guava/filament-nested-resources. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package filament-nested-resources
Filament Nested Resources
Filament Nested Resources allows you to create nested resources of any depth. This is useful for resources which are too complex for relation manager, yet don't make sense as a standalone resource.
First public release is here.
Showcase
Support us
Your support is key to the continual advancement of our plugin. We appreciate every user who has contributed to our journey so far.
While our plugin is available for all to use, if you are utilizing it for commercial purposes and believe it adds significant value to your business, we kindly ask you to consider supporting us through GitHub Sponsors. This sponsorship will assist us in continuous development and maintenance to keep our plugin robust and up-to-date. Any amount you contribute will greatly help towards reaching our goals. Join us in making this plugin even better and driving further innovation.
Installation
You can install the package via composer:
Usage
Throughout the documentation I refer to root
nested resource and child
nested resources. The only difference is that the Root
is the first resource in the relationship tree.
In the examples: ArtistResource > AlbumResource > SongResource
Artist would be the root resource, the other would be child resources.
Supported relationships
Currently we support one-to-many and polymoprhic one-to-many relationships only.
Demo Project
To better understand how nested resources work and to troubleshoot any issues you might encounter, we've created a demo laravel project: https://github.com/GuavaCZ/filament-nested-resources-demo
Quick start
In order to set up Nested Resources, you need to do these steps:
- On the resources (root and all child resources) you want to nest, add the
NestedResource
trait. You will be required to implement thegetAncestor
method. For the root resource, returnnull
, for all child resources implement it according to the documentation below. - On every page of the resources from the 1st step, add the
NestedPage
trait. - Create a
RelationManager
(Filament documentation) or aRelationPage
(Filament documentation) to bind the Resources together. Add theNestedRelationManager
trait to either of them.
Let's imagine the scenario from the Showcase screenshots, where we have this schema:
- Artist Model.
- Album Model (Belongs to Artist).
- Song Model (Belongs to Album).
First we create ArtistResource
:
Next, we create the AlbumResource
:
In every page of our ArtistResource
and AlbumResource
, we add the NestedPage
trait:
Now let`s create a new page which will be used to create child records. Let's create CreateArtistAlbum
page inside ArtistResource/Pages
:
Don`t forget to register the page in the getPages
method.
And finally we create either the AlbumsRelationManager
or if you prefer to use a Relation Page then create a ManageArtistAlbums
page. We just need to add the NestedRelationManager
trait here.
For RelationManager:
For RelationPage:
Optionally, we recommend deleting the index
and create
pages from your child NestedResources
(in this case AlbumResource).
Customizing the breadcrumbs
Every resource can control their own part of the breadcrumb, which by default consists of an index
breadcrumb and a detail
breadcrumb.
The index
breadcrumb typically redirects to the index page.
The detail
breadcrumb typically redirects to the detail (edit or view) and by default, will display the route key (ID if not configured otherwise) of the record.
You can override the label via the getBreadcrumbRecordLabel
method of a NestedResource
:
Or you can override the resource`s breadcrumb part completely, by overriding the getBreadcrumbs
method on the resource:
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Lukas Frey
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of filament-nested-resources with dependencies
spatie/laravel-package-tools Version ^1.15
livewire/livewire Version ^3.0