Skip to content

A tool for editing settings on your project using akaunting/setting package on Laravel Nova

Notifications You must be signed in to change notification settings

KosmosKosmos/nova-settings

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nova Settings

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.

Installation

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 --provider=Epigra\NovaSettings\Providers\NovaSettingsServiceProvider
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
    ];
}

Usage

Registering fields

Define the fields in your NovaServiceProvider's boot() function by calling NovaSettings::setSettingsFields().

\Epigra\NovaSettings\NovaSettingsTool::setSettingsFields([
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number').
]);

Custom formatting

If you want the value of the setting to be formatted before it's returned, pass a Closure as the second parameter to the setSettingsFields function. The function receives two arguments: key and value.

\Epigra\NovaSettings\NovaSettingsTool::setSettingsFields([
    // ... fields
], function ($key, $value) {
    if ($key === 'some_boolean_value') return boolval($value);
    return $value;
});

Configuration

Restart queue after settings are saved

If your project uses queue it is possible that you'll have to restart it each time settings are updated. This feature is turned off per default. You may turn it on by changing restart_queue value from false to true under config/nova-settings.php.

Credits

Thanks for the inspiration.

akaunting/setting

You can visit https://github.com/akaunting/setting to get more information on how to use getters/setters and facade of settings package.

optimistdigital/nova-settings

This package is inspired by optimistdigital/nova-settings

About

A tool for editing settings on your project using akaunting/setting package on Laravel Nova

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 58.2%
  • Vue 25.9%
  • HTML 12.4%
  • JavaScript 3.3%
  • CSS 0.2%