alfasix / alfakit-settings
Settings pages for Spatie Laravel Settings in AlfaKit panels.
Requires
- php: ^8.4
- alfasix/alfakit: ^0.1|@dev
- spatie/laravel-settings: ^3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
by Alfa Six
This is a read-only split of the AlfaKit monorepo. Please open issues and pull requests there.
Settings pages for Spatie Laravel Settings in AlfaKit panels. They render in React, Vue and Svelte with AlfaKit's built-in components.
Installation
composer require alfasix/alfakit-settings
Install spatie/laravel-settings and run its migration.
Usage
Generate a page (and the settings class, when it doesn't exist yet):
php artisan make:alfakit-settings-page ManageGeneral GeneralSettings
use AlfaSix\Alfakit\Forms\Components\TextInput; use AlfaSix\Alfakit\Schemas\Schema; use AlfaSix\AlfakitSettings\Pages\SettingsPage; class ManageGeneral extends SettingsPage { protected static string $settings = GeneralSettings::class; public function form(Schema $schema): Schema { return $schema->components([ TextInput::make('site_name')->required(), ]); } }
The form is filled from the settings and the save button writes them back, with mutateFormDataBeforeFill(), mutateFormDataBeforeSave(), beforeSave() / afterSave() hooks, a saved notification and canAccess() authorisation.
Discovered pages work as they are; the plugin registers pages explicitly and can group them:
use AlfaSix\AlfakitSettings\SettingsPlugin; $panel->plugin(SettingsPlugin::make()->pages([ManageGeneral::class])->navigationGroup('Settings'));
Full documentation: alfakit.dev/docs/plugins/settings.
License
MIT. See LICENSE.md.