PHP code example of bmellink / nova-settings

1. Go to this page and download the library: Download bmellink/nova-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bmellink / nova-settings example snippets


// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        new \bmellink\NovaSettings\NovaSettings
    ];
}

// Using an array
\bmellink\NovaSettings\NovaSettings::addSettingsFields([
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
]);

// OR

// Using a callable
\bmellink\NovaSettings\NovaSettings::addSettingsFields(function() {
  return [
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
  ];
});

// Using an array
\bmellink\NovaSettings\NovaSettings::addSettingsFields([
    Panel::make('Panel Title', [
      Text::make('Some setting', 'some_setting'),
      Number::make('A number', 'a_number'),
    ]),
]);

\bmellink\NovaSettings\NovaSettings::addSettingsFields([
    // ... fields
], [
  'some_boolean_value' => 'boolean',
  'some_float' => 'float',
  'some_collection' => 'collection',
  // ...
]);

\bmellink\NovaSettings\NovaSettings::addSettingsFields([
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
], [], 'Subpage');

public function tools(): array
{
    return [
        NovaSettings::make()->canSee(fn () => user()->isAdmin()),
    ];
}

Text::make('A text field')
  ->canSee(fn () => user()->isAdmin()),
bash
php artisan vendor:publish --provider="bmellink\NovaSettings\NovaSettingsServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="bmellink\NovaSettings\NovaSettingsServiceProvider" --tag="migrations"
bash
php artisan vendor:publish --provider="bmellink\NovaSettings\NovaSettingsServiceProvider" --tag="translations"