PHPackages                             rodrigofs/filament-masterdetail - 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. rodrigofs/filament-masterdetail

AbandonedArchivedLibrary[Admin Panels](/categories/admin)

rodrigofs/filament-masterdetail
===============================

Filament plugin designed specifically for managing Laravel HasMany relationships without relying on Filament's default repeater field, using instead a dedicated modal and table-based form interface.

v1.4.0(1y ago)21313[4 PRs](https://github.com/rodrigofs/filament-masterdetail/pulls)MITPHPPHP ^8.1CI passing

Since Mar 26Pushed 8mo ago1 watchersCompare

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

READMEChangelog (8)Dependencies (11)Versions (14)Used By (0)

Filament Master Detail
======================

[](#filament-master-detail)

[![Filament Master Detail](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/art/rodrigofs-filament-masterdetail.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/art/rodrigofs-filament-masterdetail.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/942cb395f66daafa348858a8f3ffe15ac8cf42ffebc8a8a887a32332e9f91c74/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f647269676f66732f66696c616d656e742d6d617374657264657461696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rodrigofs/filament-masterdetail)[![PHP Run Tests](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/run-tests.yml/badge.svg)](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/run-tests.yml)[![fix-code-style](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/fix-php-code-styling.yml/badge.svg)](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/fix-php-code-styling.yml)[![phpstan](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/phpstan.yml/badge.svg)](https://github.com/rodrigofs/filament-masterdetail/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/0d7cd02a08ae9db77bd052933b19f60b4745349c77a28f0fca707a92811feb39/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f647269676f66732f66696c616d656e742d6d617374657264657461696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rodrigofs/filament-masterdetail)

---

Overview
--------

[](#overview)

**Filament Master Detail** is a dynamic management plugin **Form Component** for HasMany (1,n) and Many to Many(n,n) relationships in FilamentPHP. It allows you to add and remove related records directly within the parent form, without the need to save the parent record first. Ideal for fast and fluid data entry scenarios.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Common Use Cases](#common-use-cases)
- [Additional Features](#additional-features)
    - [Behavior &amp; Customization](#behavior--customization)
        - [Disable Actions](#disable-actions)
        - [Slideover Mode](#slideover-mode)
        - [Set Custom Labels](#set-custom-labels)
        - [Set Modal Icon and Width](#set-modal-icon-and-width)
        - [Keep Modal Open After Adding](#keep-modal-open-after-adding)
        - [Customize Table Heading](#customize-table-heading)
        - [Preserve Field Values](#preserve-field-values)
        - [Manipulate Data Before Adding](#manipulate-data-before-adding)
        - [Add Header Actions](#add-header-actions)
- [Full Example](#full-example)
- [Editing Behavior](#editing-behavior)
- [FAQ](#faq)
- [Screenshots](#screenshots)
    - [Table View](#table-view)
    - [Add New Item](#add-new-item-in-modal)
    - [Edit Item](#edit-item-in-modal)
    - [Remove Item](#remove-item-with-confirmation)
    - [Slideover Mode](#show-slideover-mode)
    - [Video Demo](#video-demo)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security](#security-vulnerabilities)
- [License](#license)

---

Installation
------------

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10
- Filament &gt;= 3.x

### Installation Steps

[](#installation-steps)

```
  composer require rodrigofs/filament-masterdetail
```

---

Basic Usage
-----------

[](#basic-usage)

> Important: When using the table(...) method, it is not compatible with Filament's TextColumn or other default columns. You must exclusively use the DataColumn provided by this package.

### Example

[](#example)

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;
use Rodrigofs\FilamentMasterDetail\Tables\Columns\DataColumn;

MasterDetail::make('items')
    ->relationship('items')
    ->schema([
        TextInput::make('name')->required(),
        TextInput::make('description'),
    ])
    ->table([
        DataColumn::make('name'),
        DataColumn::make('description'),
    ]);
```

Define the HasMany relationship in the parent model:

```
public function items(): HasMany
{
    return $this->hasMany(Item::class);
}
```

---

Common Use Cases
----------------

[](#common-use-cases)

### Order Creation with Items

[](#order-creation-with-items)

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;
use Rodrigofs\FilamentMasterDetail\Tables\Columns\DataColumn;

MasterDetail::make('items')
    ->relationship()
    ->schema([
        Select::make('shop_product_id')
            ->label('Product')
            ->options(Product::query()->pluck('name', 'id'))
            ->required()
            ->reactive()
            ->afterStateUpdated(fn ($state, Set $set) => $set('price', Product::find($state)?->price ?? 0))
            ->distinct()
            ->disableOptionsWhenSelectedInSiblingRepeaterItems()
            ->columnSpan(['md' => 5])
            ->searchable(),

        TextInput::make('quantity')
            ->label('Quantity')
            ->numeric()
            ->default(1)
            ->required()
            ->columnSpan(['md' => 2]),

        TextInput::make('price')
            ->label('Unit Price')
            ->numeric()
            ->disabled()
            ->dehydrated()
            ->required()
            ->columnSpan(['md' => 3]),
    ])
    ->unique('shop_product_id')
    ->table([
        DataColumn::make('product.name')
            ->relationship()
            ->label('Product'),

        DataColumn::make('quantity')
            ->label('Quantity'),

        DataColumn::make('price')
            ->label('Unit Price'),

        DataColumn::make('total')
            ->formatStateUsing(fn ($rowLoop) => $rowLoop->price * $rowLoop->quantity)
            ->label('Total'),
    ]);
```

---

Additional Features
-------------------

[](#additional-features)

### Behavior &amp; Customization

[](#behavior--customization)

You can customize the behavior of the component and the appearance and behavior of the modal used to add, delete, and edit related records:

#### Disable Actions

[](#disable-actions)

Disable the default Add, Delete, and Edit actions on the component:

```
use Rodrigofs\FilamentMasterDetail\Components\MasterDetail;

// Disable actions statically
MasterDetail::make('items')
    ->addable(false)
    ->editable(false)
    ->removable(false)
    ->schema([
        // Form fields
    ]);

// Disable actions conditionally using closures
MasterDetail::make('items')
    ->addable(fn (): bool => /* condition based on $record, $get, $state, $operation and more... */ false)
    ->editable(fn (...): bool => /* condition based on $record, $get, $state, $operation and more... */ false)
    ->removable(fn (...): bool => /* condition based on $record, $get, $state, $operation and more... */ false)
    ->schema([
        // Form fields
    ]);
```

#### Slideover Mode

[](#slideover-mode)

Display the form inside a Slideover instead of a traditional modal:

```
use Rodrigofs\FilamentMasterDetail\Components\MasterDetail;

MasterDetail::make('items')
    ->slideover()
    ->schema([
        // Form fields
    ]);
```

#### Set Custom Labels

[](#set-custom-labels)

Define the labels for modal actions and headings:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->addActionLabel('Add Product')
    ->modalHeading('Add Product')
    ->modalDescription('Include a new product in this order.')
    ->modalSubmitActionLabel('Add')
    ->modalSubmitEditActionLabel('Edit')
    ->modalCancelActionLabel('Cancel');
```

#### Set Modal Icon and Width

[](#set-modal-icon-and-width)

Customize the modal icon and size:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->modalIcon('heroicon-o-plus')
    ->modalWidth('lg');
```

#### Keep Modal Open After Adding

[](#keep-modal-open-after-adding)

Prevent the modal from closing automatically after adding a record:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->modalPersistent();
```

#### Customize Table Heading

[](#customize-table-heading)

Set a custom heading for the related records table:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->heading('Order Items');
```

#### Preserve Field Values

[](#preserve-field-values)

Prevent specific fields from being cleared after adding a record:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->formExceptClear(['product_id']);
```

#### Manipulate Data Before Adding

[](#manipulate-data-before-adding)

Allow data manipulation before the record is added to the table:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->beforeAddActionExecute(fn ($state, $set) => $set('product_id', $state));
```

#### Add Header Actions

[](#add-header-actions)

Define custom actions in the header of the MasterDetail component:

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->headerActions([
       Action::make('reset')
            ->modalHeading('Are you sure?')
            ->modalDescription('All existing items will be removed from the order.')
            ->requiresConfirmation()
            ->color('danger')
            ->action(fn (Forms\Set $set) => $set('items', [])),
    ]);
```

> *There are many additional features available—more than can be covered at once. While I will continue to document them, I encourage you to freely explore all possibilities. Don’t hesitate to open an issue if you encounter any problems or have suggestions.*

---

Full Example
------------

[](#full-example)

```
use Rodrigofs\FilamentMasterDetail\Forms\Components\MasterDetail;

MasterDetail::make('items')
    ->relationship()
    ->schema([
        Select::make('product_id')
            ->label('Product')
            ->options(Product::query()->pluck('name', 'id'))
            ->required(),
        TextInput::make('quantity')
            ->numeric()
            ->required(),
    ])
    ->table([
        DataColumn::make('product.name')
            ->relationship()
            ->label('Product'),
        DataColumn::make('quantity')
            ->label('Quantity'),

    ])
    ->addActionLabel('Add Product')
    ->modalHeading('Add Product')
    ->modalDescription('Include a new product in this order.')
    ->modalIcon('heroicon-o-plus')
    ->modalWidth('lg')
    ->modalSubmitActionLabel('Add')
    ->modalCancelActionLabel('Cancel')
    ->heading('Order Items')
    ->formExceptClear(['product_id'])
    ->beforeAddActionExecute(fn ($state, $set) => $set('product_id', $state))
    ->headerActions([
        Action::make('reset')
            ->modalHeading('Are you sure?')
            ->modalDescription('All existing items will be removed from the order.')
            ->requiresConfirmation()
            ->color('danger')
            ->action(fn (Forms\Set $set) => $set('items', [])),
    ])
    ->slideOver();
```

---

Editing Behavior
----------------

[](#editing-behavior)

The editing feature works for related records defined via the relationship() method on the component.

> **Important**: This feature does not support custom statePath-based implementations that do not use the relationship() method. Relationship-based binding is required for the edit action to resolve the model instance correctly.

FAQ
---

[](#faq)

1. **Do I need to save the parent record before adding related records?***No. MasterDetail allows adding and removing related records before persisting the parent model.*
2. **Does it support other relationship types besides HasMany?**\*Currently, only HasMany relationships are supported.\* *Yes. In addition to HasMany, it is now possible to create records using BelongsToMany (many-to-many) relationships. However, attaching existing related records is not yet supported.*
3. **Is there support for editing related records?***No. Only adding and removing records is supported at the moment.**Yes. You can edit related records through an edit action.*

---

Screenshots
-----------

[](#screenshots)

### Table View

[](#table-view)

[![Table View](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/table.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/table.png)

### Add New Item in Modal

[](#add-new-item-in-modal)

[![Add New Item](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/add.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/add.png)

### Edit Item in Modal

[](#edit-item-in-modal)

[![Edit Item](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/edit.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/edit.png)

### Remove Item with Confirmation

[](#remove-item-with-confirmation)

[![Remove Item](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/remove.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/remove.png)

### Show Slideover Mode

[](#show-slideover-mode)

[![Slideover Mode](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/slideover.png)](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/slideover.png)

### Video Demo

[](#video-demo)

[![Video Demo](https://raw.githubusercontent.com/rodrigofs/filament-masterdetail/main/.github/resources/demo.png)](https://youtu.be/ONHLSC0Znew)

---

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

---

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)

- [Rodrigo Fernandes](https://github.com/rodrigofs)
- [All Contributors](../../contributors)

---

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance55

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.5% 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

Every ~4 days

Total

8

Last Release

382d ago

### Community

Maintainers

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

---

Top Contributors

[![rodrigofs](https://avatars.githubusercontent.com/u/2329113?v=4)](https://github.com/rodrigofs "rodrigofs (53 commits)")[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (12 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rodrigofs-filament-masterdetail/health.svg)

```
[![Health](https://phpackages.com/badges/rodrigofs-filament-masterdetail/health.svg)](https://phpackages.com/packages/rodrigofs-filament-masterdetail)
```

###  Alternatives

[awcodes/filament-quick-create

Plugin for Filament Admin that adds a dropdown menu to the header to quickly create new items.

246177.6k7](/packages/awcodes-filament-quick-create)[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)[geo-sot/filament-env-editor

Access .env file though Filament admin panel

2432.3k1](/packages/geo-sot-filament-env-editor)[inerba/filament-db-config

A Filament plugin for database-backed application settings and editable content, with caching and easy page generation.

329.1k](/packages/inerba-filament-db-config)[caresome/filament-neobrutalism-theme

A neobrutalism theme for FilamentPHP admin panels

303.2k](/packages/caresome-filament-neobrutalism-theme)

PHPackages © 2026

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