This Laravel Nova package allows you to create custom settings in code (using Nova's native fields) and creates a UI for the users where the settings can be edited by using akaunting/setting package.
Install the package in a Laravel Nova project via Composer:
composer require epigra/nova-settings
To publish the database migration(s) configuration of akaunting/setting
php artisan vendor:publish --tag=setting
php artisan vendor:publish --tag=nova-settings
php artisan migrate
Register the tool with Nova in the tools()
method of the NovaServiceProvider
:
// in app/Providers/NovaServiceProvider.php
public function tools()
{
return [
// ...
new \Epigra\NovaSettings\NovaSettingsTool
];
}
Define the fields in your NovaServiceProvider
's boot()
function by calling NovaSettings::addSettingsFields()
.
\Epigra\NovaSettings\NovaSettingsTool::addSettingsFields([
Text::make('Some setting', 'some_setting'),
Number::make('A number', 'a_number')
]);
// OR
// Using a callable
\Epigra\NovaSettings\NovaSettingsTool::addSettingsFields(function() {
return [
Text::make('Some setting', 'some_setting'),
Number::make('A number', 'a_number'),
];
});
This feature is turned off per default. You may turn it on by changing reload_page_on_save
value from
false
to true
under config/nova-settings.php
to reload the entire page on save. Useful when updating any Nova UI related settings.
Thanks for the inspiration.
You can visit https://github.com/akaunting/setting to get more information on how to use getters/setters and facade of settings package.
This package is inspired by optimistdigital/nova-settings