Settings module
Settings Module implements an API for adding strongly typed application settings.
Setup new settings
Settings should be assigned to a group which will collect the UI for managing related settings.
Steps required to add a settings group to a module.
Create a new settings class that extends:
Spatie\LaravelSettings\SettingsDefine a
group()method to provide a unique name for the group.Define some strongly typed properties for the settings class.
Define a
form()method to provide form inputs for the new settings properties.Define a new "migration" class in a "settings" sub-directory of the "Database/Migrations" folder for the module.
Extend the Spatie\LaravelSettings\Migrations\SettingsMigration class and add matching settings prefixed by the "group" name using "$this->migrator->add".
Extend the boot method in the
ModuleName/Provider/ModuleNameServiceProviderclass to append the settings migration folder.Add unit tests for your new settings to ensure they are migrated and can be updated.
Access settings
Accessing settings should ALWAYS be done through the service container to avoid caching issues. Use the new() helper function defined in BaseSettings:
$value = YourSettings::new()->settingName;