https://github.com/ofcold/nova-configuration-field
Dynamically create configuration items for your resources.
https://github.com/ofcold/nova-configuration-field
config laravel laravel-nova
Last synced: 11 months ago
JSON representation
Dynamically create configuration items for your resources.
- Host: GitHub
- URL: https://github.com/ofcold/nova-configuration-field
- Owner: ofcold
- Created: 2018-12-26T06:12:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-26T07:10:59.000Z (about 7 years ago)
- Last Synced: 2025-04-20T19:36:59.111Z (11 months ago)
- Topics: config, laravel, laravel-nova
- Language: PHP
- Size: 31.3 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nova-configuration-field
Dynamically create configuration items for your resources.
## Requirements
Laravel Nova.
# Installation
First install the Nova package via composer:
```bash
composer require ofcold/nova-configurations-field
```
Publish the config file:
```bash
php artisan vendor:publish --provider="Ofcold\\Configurations\\FieldServiceProvider"
```
Then run the migration
```bash
php artisan migrate
```
# Usage
Add configuration item cache key in your `.env` File
```bash
OFCOLD_CONFIGURATION_KEY=config
```
Configure different resources
```php
use Ofcold\Configurations\Configurations;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Configurations::make('Configurations')
->setConfigurations([
Text::make('foo'),
Text::make('bar')
], 'example')
];
}
```
Get configuration item from scope
```php
use Ofcold\Configurations\Repository;
Repository::scopeItems($scope)
```
Get a single configuration
```php
use Ofcold\Configurations\Repository;
// Use scope and key
// Example: example::foo
Repository::get('example::foo')
```
Get a single configuration value
```php
use Ofcold\Configurations\Repository;
// Use scope and key
// Example: example::foo
Repository::getValue('example::foo')
```