https://github.com/elsayed85/nova-settings
This Laravel Nova settings tool based on env, using nativ nova fields and resources
https://github.com/elsayed85/nova-settings
Last synced: 6 months ago
JSON representation
This Laravel Nova settings tool based on env, using nativ nova fields and resources
- Host: GitHub
- URL: https://github.com/elsayed85/nova-settings
- Owner: elsayed85
- License: mit
- Fork: true (stepanenko3/nova-settings)
- Created: 2023-01-14T10:08:37.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-14T10:08:57.000Z (over 3 years ago)
- Last Synced: 2024-04-22T19:10:12.456Z (about 2 years ago)
- Language: PHP
- Homepage:
- Size: 175 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Nova Settings
[](https://packagist.org/packages/stepanenko3/nova-settings)
[](https://packagist.org/packages/stepanenko3/nova-settings)
[](https://packagist.org/packages/stepanenko3/nova-settings)

## Description
This Laravel Nova settings tool based on env, using nativ nova fields and resources
## Features
- Using native Nova resources
- Fully responsive
- Dark mode support
- Support all packages. Like nova-tabs, activity-log, etc.
- Different settings depending on the current Env
- Separation of settings into different classes
- Customizable model and resource
## Requirements
- `php: >=8.0`
- `laravel/nova: ^4.0`
## Installation
```bash
# Install the package
composer require stepanenko3/nova-settings
```
Publish the config file:
``` bash
php artisan vendor:publish --provider="Stepanenko3\NovaSettings\ToolServiceProvider" --tag="config"
```
Publish the migration file:
``` bash
php artisan vendor:publish --provider="Stepanenko3\NovaSettings\ToolServiceProvider" --tag="migrations"
```
And run `php artisan migrate`
Next up, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.
```php
// in app/Providers/NovaServiceProvder.php
// ...
public function tools()
{
return [
// ...
new \Stepanenko3\NovaSettings\NovaSettingsTool(),
];
}
```
Create your own configuration classes in app/Nova/Settings
```php
// in app/Nova/Settings/Demo.php
\Stepanenko3\NovaSettings\Models\Settings::class,
'resource' => \Stepanenko3\NovaSettings\Resources\Settings::class,
'types' => [
\App\Nova\Settings\Demo::class, // Add this line
],
];
```
## Usage
Click on the `"Settings"` menu item in your Nova app to see the tool.
Use helper function for access the settings
``` php
// settings(string|null $section, string|null $key = null, string|null $default = null, string|null $env = null)
settings('demo', 'key', 'defaultValue', config('app.env'))
```
Get `cart_link` value from `General` settings in current Env
```php
settings('general', 'cart_link')
```
Get all `General` settings
```php
settings('general')
```
Get `cart_link` value from `General` settings in specific Env with default value
```php
settings(
section: 'general',
key: 'cart_link',
default: true,
env: 'production'
);
// OR
settings('general', 'cart_link', true, 'production');
```
## Configuration
All the configuration is managed from a single configuration file located in `config/nova-settings.php`
### Extends default model
Create your own model that will extends `\Stepanenko3\NovaSettings\Models\Settings`
```php
// in app/Models/Settings.php
logFillable()
->logOnlyDirty();
}
}
```
Declare your model `'model' => \App\Models\Settings::class,` in `config/nova-settings.php`
## Extends default Nova resource
Create your own resource that will extends `\Stepanenko3\NovaSettings\Resources\Settings`
``` php
// in app/Nova/Settings.php
\App\Nova\Settings::class,` in `config/nova-settings.php`
Don't forget to create `App\Nova\ActivityLog`
### Screenshots

## Credits
- [Artem Stepanenko](https://github.com/stepanenko3)
## Contributing
Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.
## License
This package is open-sourced software licensed under the [MIT license](LICENSE.md).