PHPackages                             valourite/dynamic-models - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. valourite/dynamic-models

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

valourite/dynamic-models
========================

A laravel filament plugin for creating dynamic models.

v2.1.11(7mo ago)151022[3 issues](https://github.com/Valourite/dynamic-models/issues)MITPHPPHP ^8.2

Since Jul 3Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/Valourite/dynamic-models)[ Packagist](https://packagist.org/packages/valourite/dynamic-models)[ RSS](/packages/valourite-dynamic-models/feed)WikiDiscussions v2.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cf48d4f841e7cc4d588f2a135bc313b770882f9d0c9a64051b8aa49e94732921/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76616c6f75726974652f64796e616d69632d6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/valourite/dynamic-models)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](MIT)[![Total Downloads](https://camo.githubusercontent.com/09b3a2881edc3fe1f3366bdba335f8a7dd9553368638eb242d7beb4f31a9f9d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76616c6f75726974652f64796e616d69632d6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/valourite/dynamic-models)

Dynamic Models for Filament &amp; Laravel
=========================================

[](#dynamic-models-for-filament--laravel)

**Dynamic Models** is a Laravel package built on top of [Filament v4](https://filamentphp.com) that allows user to define base models which they can then add information to depending on the form used on model creation.

- This concept can be seen as `database inheritance`.
- The concept is that we can define a base table `User`, then create different model types for different types of users, allowing all user models that get created to `inherit` the base user table required fields as well as having to input newly required fields based on the form the model is attached to.
- This allows us to define a single base model, and dynamically create new types for that model.

Key Features:

- **Dynamic Model Creation** - Allow the same model to host different values on different instances
- **Version control** - The ability to implement custom version control code when the model type changes, or use the default strategy implemented.
- **Response storage** - Separate table for model instance values with schema versioning
- **Visual builder** - Repeatable model type sections and fields
- **Type safety** - Strongly typed fields with validation support

---

Features
--------

[](#features)

- Filament v4 integration - Native UI components and resource management
- Visual dynamic model builder - Create new model types with sections, fields, and options for dynamic models
- Automatic versioning - New form versions created on schema changes
- Response storage - Dedicated `model_instances` table with JSON data
- Data integrity - Responses always linked to their model type version
- Field types - Text, number, email, select, radio, date/time, and more
- Custom IDs - Unique identifiers for model type field data binding

---

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

[](#installation)

> Requires Laravel 12+ and Filament 4+

1. Install via Composer:

```
composer require valourite/dynamic-models
```

2. Run the installer:

```
php artisan dynamic-models:install
```

This will:

- Publish configuration to `config/dynamic-models.php`
- Create database tables:
    - `model_types` (model type definitions)
    - `model_instances` (model instance data)

---

Register the plugin
-------------------

[](#register-the-plugin)

In your `PanelProvider`:

```
use Valourite\DynamicModels\DynamicModelsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            DynamicModelsPlugin::make(),
        ]);
}
```

---

Usage
-----

[](#usage)

### 1. Prepare Your Model

[](#1-prepare-your-model)

Use the `isDynamic` trait:

```
use Valourite\DynamicModels\Concerns\isDynamic;

class Client extends Model
{
    use isDynamic;

}
```

This will allow your model to link to a model type as well as store the model instance data upon creation. Note: Only one `model instance` can belong to one model as a `model instance` is essentially an extension of the model's required fields.

---

### 2. Update Filament components

[](#2-update-filament-components)

This allows the form schema to be injected into your resource form schema.

```
use Valourite\DynamicModels\Filament\Support\Injectors\ModelTypeSchemaInjector;

class ClientForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                // Your existing fields
                TextInput::make('name')->required(),
                TextInput::make('email')->email()->required(),

                //inject form schema
                ...ModelTypeSchemaInjector::make()
            ]);
    }
}
```

This allows the table schema to be injected into your resource's table schema

- This would inidicate the type of model that has been created.

```
use Valourite\DynamicModels\Filament\Support\Injectors\ModelTypeTableInjector;

class ClientTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('name')
                    ->searchable(),
                TextColumn::make('email')
                    ->searchable(),

                //inject table schema
                ...ModelTypeTableInjector::make(),
            ]);
    }
}
```

This allows the infolist schema to be injected into your resource's infolist schema.

```
use Valourite\DynamicModels\Filament\Support\Injectors\ModelTypeInfoListInjector;

class ClientInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                // Your existing info fields
                TextEntry::make('name'),
                TextEntry::make('email'),

                // Add form response display
                ...ModelTypeInfoListInjector::make()
            ])
    }
}
```

---

### 3. Add Traits Into The Create And Edit Page Of Your Resource

[](#3-add-traits-into-the-create-and-edit-page-of-your-resource)

```
class CreateClient extends CreateRecord
{
    use HandlesModelInstance;
    use CustomNotification;

    protected static string $resource = ClientResource::class;
}
```

```
class EditClient extends EditRecord
{
    use HandlesModelInstance;
    use CustomNotification;

    protected static string $resource = ClientResource::class;
}
```

This handles:

- Saving the model type values into `model_instance`
- Linking the correct `model_type_id`, version, and structure
- Allowing updates to be made to the model instance values

We can display a custom message set inside the model type by making use of the trait `CustomNotification`

---

How It Works
------------

[](#how-it-works)

1. **Form Creation**:

    - Model Ttpes are created in the Filament admin with versioned schemas
    - Each schema change creates a new model type with an updated version (depends on config settings)
    - All changes to model type data unrelated to the model type schema will not generate a new model type, but rather update the current version (depends on config settings)
    - Existing model instance values remain linked to their original model type version
2. **Model Instance Handling**:

    - Model instance values are stored in `model_instances` table when a new model is created from a model type
    - Each model instance references the exact model type version used
    - Data stored as JSON with field IDs as keys
3. **Data Integrity**:

    - Model Type schema changes don't affect existing responses
    - Model instances will always link to the model type they were generated from
    - Historical data remains viewable with original schema
    - Version tracking through semantic versioning (major.minor.patch)

---

Testing
-------

[](#testing)

No tests have been written as of yet

---

Roadmap
-------

[](#roadmap)

- Core form builder implementation
- Version control system
- Response storage system
- Filament v4 integration
- Extract model instance json data in seperate key:value table
- Add more functionality to sections (non-collapsible)
- File upload field support
- More customization on fields and sections
- Allow users to hook into modelType lifecycle
- Allow user to style infolist and form sections
- Implementing prefix and suffix icons with colour handling
- Advanced validation rules

---

📄 License
---------

[](#-license)

MIT © [Dayne Valourite](https://github.com/dayne-valourite)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance61

Regular maintenance activity

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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 ~6 days

Total

19

Last Release

213d ago

Major Versions

v1.0.2 → v2.0.02025-07-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/3957ffec88ac8b706b706b8d4c6bc0bce6b0fa0ff85b8665e10a081facc018b2?d=identicon)[Dayne-Valourite](/maintainers/Dayne-Valourite)

---

Top Contributors

[![Dayne-Valourite](https://avatars.githubusercontent.com/u/184140704?v=4)](https://github.com/Dayne-Valourite "Dayne-Valourite (106 commits)")[![nielsdrost7](https://avatars.githubusercontent.com/u/47660417?v=4)](https://github.com/nielsdrost7 "nielsdrost7 (4 commits)")[![larsbo](https://avatars.githubusercontent.com/u/754074?v=4)](https://github.com/larsbo "larsbo (1 commits)")

---

Tags

filamentphpfilamentpluginforminheritancelaravelmodels

### Embed Badge

![Health badge](/badges/valourite-dynamic-models/health.svg)

```
[![Health](https://phpackages.com/badges/valourite-dynamic-models/health.svg)](https://phpackages.com/packages/valourite-dynamic-models)
```

###  Alternatives

[stephenjude/filament-feature-flags

Filament implementation of feature flags and segmentation with Laravel Pennant.

118126.9k](/packages/stephenjude-filament-feature-flags)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[joaopaulolndev/filament-general-settings

Filament package to manage general settings

18129.7k](/packages/joaopaulolndev-filament-general-settings)[marcelweidum/filament-expiration-notice

Customize the livewire expiration notice

9169.0k4](/packages/marcelweidum-filament-expiration-notice)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[marjose123/filament-webhook-server

Send webhooks from your filament apps

507.3k2](/packages/marjose123-filament-webhook-server)

PHPackages © 2026

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