Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spatie Laravel Settings Plugin Laravel Package

filament/spatie-laravel-settings-plugin

Filament plugin to manage app settings stored with spatie/laravel-settings. Generate settings pages, build forms with Filament fields that map to your settings class properties, and automatically load/save values from the database with minimal setup.

View on GitHub
Deep Wiki
Context7

Filament Spatie Settings Plugin

Installation

Install the plugin with Composer:

composer require filament/spatie-laravel-settings-plugin:"^5.0" -W

Preparing your page class

Settings pages are Filament pages that extend the Filament\Pages\SettingsPage class.

This package uses the spatie/laravel-settings package to store and retrieve settings via the database.

Before you start, create a settings class in your app/Settings directory, and a database migration for it. You can find out more about how to do this in the Spatie documentation.

Once you've created your settings class, you can create a settings page in Filament for it using the following command:

php artisan make:filament-settings-page ManageFooter FooterSettings

In this example, you have a FooterSettings class in your app/Settings directory.

In your new settings page class, generated in the app/Filament/Pages directory, you will see the static $settings property assigned to the settings class:

protected static string $settings = FooterSettings::class;

Building a form

You must define a form schema to interact with your settings class inside the form() method.

Since the Form Builder is installed in the Panel Builder by default, you may use any form fields or layout components you like:

use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;

public function form(Schema $schema): Schema
{
    return $schema
        ->components([
            TextInput::make('copyright')
                ->label('Copyright notice')
                ->required(),
            Repeater::make('links')
                ->schema([
                    TextInput::make('label')->required(),
                    TextInput::make('url')
                        ->url()
                        ->required(),
                ]),
        ]);
}

The name of each form field must correspond with the name of the property on your settings class.

The form will automatically be filled with settings from the database, and saved without any extra work.

Authorization

By default, no users are restricted from accessing settings pages. To prevent a page from being accessed altogether, define a canAccess() method in the page class, and return true or false based on the user's permissions:

public static function canAccess(): bool
{
    return auth()->user()->isAdmin();
}

If the user has access to the page, you can also prevent them from editing the settings. This is useful if a user needs to be able to check the current state of the settings, but not change them. In this case, the settings form would be "disabled" and read-only. Define the canEdit() method in the page class, and return true or false based on the user's permissions:

public static function canEdit(): bool
{
    return auth()->user()->isAdmin();
}

Note: canEdit() only gates saving — it does not prevent a user from loading the page and reading every field's current value. If the settings themselves are sensitive (API keys, internal flags, etc.), restrict viewing with canAccess() (and/or route middleware) instead of relying on canEdit().

Publishing translations

If you wish to translate the package, you may publish the language files using:

php artisan vendor:publish --tag=filament-spatie-laravel-settings-plugin-translations
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony