nalzai35 / filament-settings
This is my package filament-settings
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
This package is auto-updated.
Last update: 2024-10-20 08:09:15 UTC
README
This package adds a settings page in the filaments stored in your database.
Installation
You can install the package via composer:
composer require nalzai35/filament-settings
Add the plugin to your desired Filament panel:
use Nalzai35\FilamentSettings\FilamentSettingsPlugin; class FilamentPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ FilamentSettingsPlugin::make() ]); } }
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-settings-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-settings-config"
This is the contents of the published config file:
return [ 'database_table_name' => 'settings', 'cache_key' => 'settings' ];
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-settings-views"
Usage
Create a settings page at app/Filament/Pages/Settings/Settings.php
:
namespace App\Filament\Pages\Settings; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Nalzai35\FilamentSettings\Pages\SettingsPage; class Settings extends SettingsPage { protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth'; public function form(Form $form): Form { return $form ->schema([ Forms\Components\Tabs::make('settings') ->schema([ Forms\Components\Tabs\Tab::make('General') ->statePath('general') ->schema([ Forms\Components\TextInput::make('brand_name') ->required() ]), Forms\Components\Tabs\Tab::make('Seo Meta') ->statePath('seo_meta') ->schema([ Forms\Components\Section::make('Home Page') ->statePath('home_page') ->collapsible() ->schema([ Forms\Components\TextInput::make('title'), Forms\Components\Textarea::make('description') ]) ]) ]), ]) ->columns(1); } }
Retrieving settings
You can retrieve settings using the helper function setting()
, like the config()
function in Laravel:
setting('general.name'); // Retrieve a default value if the configuration value does not exist... setting('general.name', 'Filament Settings'); // To set configuration values at runtime setting(['general.timezone' => 'America/Chicago']);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.