District Core Developer DocsDistrict Core Developer Docs
Developers
Boilerplate
Modules
Bitbucket
Developers
Boilerplate
Modules
Bitbucket
  • Modules

    • ABN
    • ActivityLog
    • AnalyticsApi
    • ApiConnector
    • BlockApi
    • CategoryApi
    • CloneApi
    • CommentApi
    • ContentApi
    • Core
    • Documents
    • EmbedApi
    • Event
    • ExportApi
    • FeatureApi
    • FormApi
    • GTM
    • GalleryApi
    • HelpApi
    • Hotspot
    • IdeaSurvey
    • ImportApi
    • InteractionsApi
    • Intercom
    • MailApi
    • MapApi
    • MapSurvey
    • MediaApi
    • MenuApi
    • MetaTagApi
    • NlpApi
    • NotificationApi
    • Page
    • ParentableContent
    • PaymentApi
    • PermissionsApi
    • Postcode
    • ReCaptcha
    • Redirects
    • Renderer
    • ReportApi
    • RestrictionApi
    • RevisionApi
    • SearchApi
    • Settings
    • ShareableApi
    • Slack
    • SlugApi
    • SubscribableApi
    • Survey
    • Team
    • TenantApi
    • TestApi
    • ThemeApi
    • Timeline
    • TranslationApi
    • Update
    • Users
    • VisualisationApi
    • WorkflowApi
    • Wysiwyg

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.

  1. Create a new settings class that extends: Spatie\LaravelSettings\Settings

  2. Define a group() method to provide a unique name for the group.

  3. Define some strongly typed properties for the settings class.

  4. Define a form() method to provide form inputs for the new settings properties.

  5. 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".

  6. Extend the boot method in the ModuleName/Provider/ModuleNameServiceProvider class to append the settings migration folder.

  7. 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;
Edit this page
Prev
SearchApi
Next
ShareableApi