PHPackages                             benjaminhansen/filament-nested-resources - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. benjaminhansen/filament-nested-resources

ActiveLibrary[Admin Panels](/categories/admin)

benjaminhansen/filament-nested-resources
========================================

v1.0(2mo ago)02MITPHP

Since Feb 25Pushed 2mo agoCompare

[ Source](https://github.com/benjaminhansen/filament-nested-resources)[ Packagist](https://packagist.org/packages/benjaminhansen/filament-nested-resources)[ GitHub Sponsors](https://github.com/GuavaCZ)[ RSS](/packages/benjaminhansen-filament-nested-resources/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

[![Filament Cluster Banner](docs/images/banner.jpg)](docs/images/banner.jpg)

Filament Nested Resources
=========================

[](#filament-nested-resources)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5ded9056b5a5cfcfd581dbb8ab7c1610e23d198edbb4510e223974e9ca881adb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67756176612f66696c616d656e742d6e65737465642d7265736f75726365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guava/filament-nested-resources)[![Total Downloads](https://camo.githubusercontent.com/f0bcbe033a8d2de098dc6b989a98c8aef04ad2543090f5917d743c454d561785/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67756176612f66696c616d656e742d6e65737465642d7265736f75726365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/guava/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.

[](#first-public-release-is-here)

Showcase
--------

[](#showcase)

[![Screenshot 1](https://github.com/GuavaCZ/filament-nested-resources/raw/main/docs/images/screenshot_01.png)](https://github.com/GuavaCZ/filament-nested-resources/raw/main/docs/images/screenshot_01.png)[![Screenshot 2](https://github.com/GuavaCZ/filament-nested-resources/raw/main/docs/images/screenshot_02.png)](https://github.com/GuavaCZ/filament-nested-resources/raw/main/docs/images/screenshot_02.png)

Support us
----------

[](#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
------------

[](#installation)

You can install the package via composer:

```
composer require guava/filament-nested-resources
```

Usage
-----

[](#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 &gt; AlbumResource &gt; SongResource

Artist would be the root resource, the other would be child resources.

### Supported relationships

[](#supported-relationships)

Currently we support **one-to-many** and **polymoprhic one-to-many** relationships only.

### Demo Project

[](#demo-project)

To better understand how nested resources work and to troubleshoot any issues you might encounter, we've created a demo laravel project:

### Quick start

[](#quick-start)

In order to set up Nested Resources, you need to do these steps:

1. On the resources (root and all child resources) you want to nest, add the `NestedResource` trait. You will be required to implement the `getAncestor` method. For the root resource, return `null`, for all child resources implement it according to the documentation below.
2. On every page of the resources from the 1st step, add the `NestedPage` trait.
3. Create a `RelationManager` ([Filament documentation](https://filamentphp.com/docs/3.x/panels/resources/relation-managers#creating-a-relation-manager)) or a `RelationPage` ([Filament documentation](https://filamentphp.com/docs/3.x/panels/resources/relation-managers#relation-pages)) to bind the Resources together. Add the `NestedRelationManager` trait to either of them.

Let's imagine the scenario from the Showcase screenshots, where we have this schema:

1. Artist Model.
2. Album Model (Belongs to Artist).
3. Song Model (Belongs to Album).

First we create `ArtistResource`:

```
use Filament\Resources\Resource;
use Guava\FilamentNestedResources\Concerns\NestedResource;

class ArtistResource extends Resource
{
    use NestedResource;

    // If using Relation Manager:
    public static function getRelations(): array
    {
        return [
            AlbumsRelationManager::class,
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListArtists::route('/'),
            'create' => Pages\CreateArtist::route('/create'),
            'edit' => Pages\EditArtist::route('/{record}/edit'),
            'view' => Pages\ViewArtist::route('/{record}'),

            // In case of relation page.
            // Make sure the name corresponds to the name of your actual relationship on the model.
            'albums' => Pages\ManageArtistAlbums::route('/{record}/albums'),

            // Needed to create child records
            // The name should be '{relationshipName}.create':
            'albums.create' => Pages\CreateArtistAlbum::route('/{record}/albums/create'),
        ];
    }

    public static function getAncestor(): ?Ancestor
    {
        return null;
    }
}
```

Next, we create the `AlbumResource`:

```
use Filament\Resources\Resource;
use Guava\FilamentNestedResources\Concerns\NestedResource;

class AlbumResource extends Resource
{
    use NestedResource;

    public static function getRelations(): array
    {
        return [
            // Repeat the same for Song Resource
        ];
    }

    public static function getAncestor() : ?Ancestor
    {
        // Configure the ancestor (parent) relationship here
        return Ancestor::make(
            'albums', // Relationship name
            'artist', // Inverse relationship name
        );
    }
}
```

In every page of our `ArtistResource` and `AlbumResource`, we add the `NestedPage` trait:

```
use Filament\Resources\Pages\CreateRecord;
use Guava\FilamentNestedResources\Concerns\NestedPage;

class CreateArtist extends CreateRecord
{
    use NestedPage;

    //
}
```

```
use Filament\Resources\Pages\EditRecord;
use Guava\FilamentNestedResources\Concerns\NestedPage;

class EditArtist extends EditRecord
{
    use NestedPage;

    //
}
```

```
use Filament\Resources\Pages\ListRecords;
use Guava\FilamentNestedResources\Concerns\NestedPage;

class ListArtists extends ListRecords
{
    use NestedPage;

    //
}
```

Now let`s create a new page which will be used to create child records. Let's create `CreateArtistAlbum` page inside `ArtistResource/Pages`:

```
use Guava\FilamentNestedResources\Pages\CreateRelatedRecord;
use Guava\FilamentNestedResources\Concerns\NestedPage;

class CreateArtistAlbum extends CreateRelatedRecord
{
    use NestedPage;

    // This page also needs to know the ancestor relationship used (just like relation managers):
    protected static string $relationship = 'albums';

    // We can usually guess the nested resource, but if your app has multiple resources for this
    // model, you will need to explicitly define it
    // public static string $nestedResource = AlbumResource::class;
}
```

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:

```
use Filament\Resources\RelationManagers\RelationManager;
use Guava\FilamentNestedResources\Concerns\NestedRelationManager;

class AlbumsRelationManager extends RelationManager
{
    use NestedRelationManager;

    // We can usually guess the nested resource, but if your app has multiple resources for this
    // model, you will need to explicitly define the it
    // public static string $nestedResource = AlbumResource::class;
}
```

For RelationPage:

```
use Filament\Resources\Pages\ManageRelatedRecords;
use Guava\FilamentNestedResources\Concerns\NestedPage;
use Guava\FilamentNestedResources\Concerns\NestedRelationManager;

class ManageArtistAlbums extends ManageRelatedRecords
{
    use NestedPage; // Since this is a standalone page, we also need this trait
    use NestedRelationManager;

    //
}
```

Optionally, we recommend deleting the `index` and `create` pages from your child `NestedResources` (in this case AlbumResource).

### Customizing the breadcrumbs

[](#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`:

```
public static function getBreadcrumbRecordLabel(Model $record)
{
    return $record->first_name . ' ' . $record->last_name;
}
```

Or you can override the resource`s breadcrumb part completely, by overriding the `getBreadcrumbs` method on the resource:

```
public static function getBreadcrumbs(Model $record, string $operation): array
{
    return [
        'my-custom-url' => 'My custom label',
];
}
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](./.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Lukas Frey](https://github.com/GuavaCZ)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance91

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 78.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

72d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac0d1695abbb15119d36a62efc555e66406f6d4396a6bc81814ec3eff417312c?d=identicon)[benjaminhansen](/maintainers/benjaminhansen)

---

Top Contributors

[![lukas-frey](https://avatars.githubusercontent.com/u/10926334?v=4)](https://github.com/lukas-frey "lukas-frey (54 commits)")[![brentkelly](https://avatars.githubusercontent.com/u/2694025?v=4)](https://github.com/brentkelly "brentkelly (4 commits)")[![acepoblete](https://avatars.githubusercontent.com/u/4582575?v=4)](https://github.com/acepoblete "acepoblete (3 commits)")[![gpibarra](https://avatars.githubusercontent.com/u/21188012?v=4)](https://github.com/gpibarra "gpibarra (2 commits)")[![benjaminhansen](https://avatars.githubusercontent.com/u/17499722?v=4)](https://github.com/benjaminhansen "benjaminhansen (2 commits)")[![Blackpig](https://avatars.githubusercontent.com/u/1029317?v=4)](https://github.com/Blackpig "Blackpig (1 commits)")[![danilogiacomi](https://avatars.githubusercontent.com/u/66949?v=4)](https://github.com/danilogiacomi "danilogiacomi (1 commits)")[![george-raphael](https://avatars.githubusercontent.com/u/11408141?v=4)](https://github.com/george-raphael "george-raphael (1 commits)")[![jamessessford](https://avatars.githubusercontent.com/u/17096446?v=4)](https://github.com/jamessessford "jamessessford (1 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/benjaminhansen-filament-nested-resources/health.svg)

```
[![Health](https://phpackages.com/badges/benjaminhansen-filament-nested-resources/health.svg)](https://phpackages.com/packages/benjaminhansen-filament-nested-resources)
```

###  Alternatives

[filament/support

Core helper methods and foundation code for all Filament packages.

2323.9M151](/packages/filament-support)[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[ralphjsmit/laravel-filament-seo

A package to combine the power of Laravel SEO and Filament Admin.

15398.7k10](/packages/ralphjsmit-laravel-filament-seo)[andreia/filament-ui-switcher

Add a modal with options to switch between different UI layouts and styles (colors, fonts, font sizes).

233.8k](/packages/andreia-filament-ui-switcher)[geo-sot/filament-env-editor

Access .env file though Filament admin panel

2432.3k1](/packages/geo-sot-filament-env-editor)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
