An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Nova Settings

[![Latest Version on Packagist](https://img.shields.io/packagist/v/stepanenko3/nova-settings.svg?style=flat-square)](https://packagist.org/packages/stepanenko3/nova-settings)
[![Total Downloads](https://img.shields.io/packagist/dt/stepanenko3/nova-settings.svg?style=flat-square)](https://packagist.org/packages/stepanenko3/nova-settings)
[![License](https://poser.pugx.org/stepanenko3/nova-settings/license)](https://packagist.org/packages/stepanenko3/nova-settings)

![screenshot of tool](screenshots/tool.png)

## 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

![screenshot of tool](screenshots/tool-dark.png)

## 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).