Skip to content

Dynamically create configuration items for your resources.

Notifications You must be signed in to change notification settings

ofcold/nova-configuration-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Dec 26, 2018
31f6af9 · Dec 26, 2018

History

7 Commits
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018
Dec 26, 2018

Repository files navigation

nova-configuration-field

Dynamically create configuration items for your resources.

Requirements

Laravel Nova.

Installation

First install the Nova package via composer:

composer require ofcold/nova-configurations-field

Publish the config file:

php artisan vendor:publish --provider="Ofcold\\Configurations\\FieldServiceProvider"

Then run the migration

php artisan migrate

Usage

Add configuration item cache key in your .env File

OFCOLD_CONFIGURATION_KEY=config

Configure different resources

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

use Ofcold\Configurations\Repository;

Repository::scopeItems($scope)

Get a single configuration

use Ofcold\Configurations\Repository;
// Use scope and key
// Example: example::foo
Repository::get('example::foo')

Get a single configuration value

use Ofcold\Configurations\Repository;
// Use scope and key
// Example: example::foo
Repository::getValue('example::foo')