PHPackages                             sitesource/laravel-polymorphic-settings-filament - 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. sitesource/laravel-polymorphic-settings-filament

ActiveLibrary[Admin Panels](/categories/admin)

sitesource/laravel-polymorphic-settings-filament
================================================

Filament integration for sitesource/laravel-polymorphic-settings — base page class and trait that auto-bind settings to Filament forms.

v0.2.0(1mo ago)035MITPHPPHP ^8.2||^8.3||^8.4||^8.5CI passing

Since Apr 25Pushed 1mo agoCompare

[ Source](https://github.com/sitesource/laravel-polymorphic-settings-filament)[ Packagist](https://packagist.org/packages/sitesource/laravel-polymorphic-settings-filament)[ Docs](https://github.com/sitesource/laravel-polymorphic-settings-filament)[ GitHub Sponsors](https://github.com/SiteSource)[ RSS](/packages/sitesource-laravel-polymorphic-settings-filament/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (15)Versions (4)Used By (0)

Filament integration for laravel-polymorphic-settings
=====================================================

[](#filament-integration-for-laravel-polymorphic-settings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/626146a478270f4a1958e763bf8337b27b5d5490eeb0156c9230463e70caba7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73697465736f757263652f6c61726176656c2d706f6c796d6f72706869632d73657474696e67732d66696c616d656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sitesource/laravel-polymorphic-settings-filament)[![GitHub Tests Action Status](https://camo.githubusercontent.com/78ec3c85f43128978af64c35748e9b2df83faec2945e69288d8fae5c1fa9ee73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73697465736f757263652f6c61726176656c2d706f6c796d6f72706869632d73657474696e67732d66696c616d656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sitesource/laravel-polymorphic-settings-filament/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/dafc0f56741ba270510e1d8d94b6efd472d4e663fa8856b44d26ad0f1df127d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73697465736f757263652f6c61726176656c2d706f6c796d6f72706869632d73657474696e67732d66696c616d656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sitesource/laravel-polymorphic-settings-filament)

A base [Filament](https://filamentphp.com) page class and helper trait that auto-bind your form schema to [`sitesource/laravel-polymorphic-settings`](https://github.com/sitesource/laravel-polymorphic-settings). Stop hand-rolling `mount()` / `save()` plumbing on every settings page.

```
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
use SiteSource\PolymorphicSettings\Filament\Pages\PolymorphicSettingsPage;

class CommerceSettings extends PolymorphicSettingsPage
{
    protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';
    protected static string $view = 'filament.pages.commerce-settings';

    public function form(Schema $schema): Schema
    {
        return $schema->components([
            Toggle::make('commerce.stripe.enabled'),
            TextInput::make('commerce.stripe.public_key'),
            TextInput::make('commerce.stripe.secret_key')->password(),  // auto-encrypts
        ])->statePath('data');
    }
}
```

That's it. Mount pulls every field's current value from the settings store. Save persists every field back, encrypting any `TextInput->password()` field at rest. No `mount()` or `save()` to write yourself.

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

[](#installation)

```
composer require sitesource/laravel-polymorphic-settings-filament
```

You'll also need the core package installed and migrated:

```
php artisan polymorphic-settings:install
```

Filament **4.x or 5.x** is required. (Filament 3.x is supported by the v0.1.x line of this package.)

Usage
-----

[](#usage)

### Global settings page

[](#global-settings-page)

The default scope is global — settings live alongside `PolymorphicSettings::global()` reads/writes:

```
class GeneralSettings extends PolymorphicSettingsPage
{
    public function form(Schema $schema): Schema
    {
        return $schema->components([
            TextInput::make('site_title'),
            TextInput::make('contact_email'),
        ])->statePath('data');
    }
}
```

### Scoped to a model (per-team, per-tenant, per-user)

[](#scoped-to-a-model-per-team-per-tenant-per-user)

Override `scopeFor()` to return the model whose settings you're editing:

```
class TeamSettings extends PolymorphicSettingsPage
{
    public function form(Schema $schema): Schema
    {
        return $schema->components([
            TextInput::make('theme.primary_color'),
            TextInput::make('theme.logo_url'),
        ])->statePath('data');
    }

    protected function scopeFor(): ?Model
    {
        return auth()->user()->currentTeam;
    }
}
```

### Encryption

[](#encryption)

Any `TextInput` marked with `->password()` is automatically persisted as `encrypted: true`. The Filament form continues to work normally — the user types a plaintext value, the page encrypts on save, and the next mount decrypts transparently.

```
TextInput::make('stripe.secret_key')->password()
```

### Customising the post-save UX

[](#customising-the-post-save-ux)

Default behaviour is a Filament success notification. Override `onSaved()` to do anything else.

```
protected function onSaved(): void
{
    parent::onSaved();
    Cache::tags('navigation')->flush();
}
```

Trait variant: `BindsToSettings`
--------------------------------

[](#trait-variant-bindstosettings)

If you want to keep your own `Page` base (or use this on any Livewire component, not just Filament pages), use the trait:

```
use SiteSource\PolymorphicSettings\Filament\Concerns\BindsToSettings;

class MyPage extends Page
{
    use BindsToSettings;

    public ?array $data = [];

    public function mount(): void
    {
        $this->form->fill($this->fillFromSettings([
            'commerce.stripe.enabled',
            'commerce.stripe.public_key',
            'commerce.stripe.secret_key',
        ]));
    }

    public function save(): void
    {
        $this->persistToSettings(
            $this->form->getState(),
            encryptedKeys: ['commerce.stripe.secret_key'],
        );
    }

    protected function settingsScope(): ?Model
    {
        return null;
    }
}
```

The trait gives you `fillFromSettings(array $keys): array` and `persistToSettings(array $values, array $encryptedKeys = []): void`. You own the form schema and the lifecycle — the trait just bulk-reads and bulk-writes the store.

Testing
-------

[](#testing)

```
composer test
```

13 tests, 23 assertions. PHPStan level 5 + Pint clean.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

Credits
-------

[](#credits)

- [Nathan Call](https://github.com/nathancall)

License
-------

[](#license)

MIT — see [LICENSE.md](LICENSE.md).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19826928?v=4)[Nathan Call](/maintainers/nathancall)[@nathancall](https://github.com/nathancall)

---

Tags

laravelconfigurationSettingsadminfilamentfilamentphplaravel-settingspolymorphicpolymorphic-settings

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sitesource-laravel-polymorphic-settings-filament/health.svg)

```
[![Health](https://phpackages.com/badges/sitesource-laravel-polymorphic-settings-filament/health.svg)](https://phpackages.com/packages/sitesource-laravel-polymorphic-settings-filament)
```

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament admin panels.

2210.5k](/packages/mradder-filament-logger)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17758.9k2](/packages/stephenjude-filament-jetstream)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

127173.7k3](/packages/dotswan-filament-map-picker)[guava/filament-knowledge-base

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

207140.2k1](/packages/guava-filament-knowledge-base)[stephenjude/filament-debugger

About

103150.5k2](/packages/stephenjude-filament-debugger)

PHPackages © 2026

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