PHP code example of weslal / nova-settings-tool

1. Go to this page and download the library: Download weslal/nova-settings-tool 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/ */

    

weslal / nova-settings-tool example snippets


use WesLal\NovaSettingsTool\NovaSettingsTool;

// ...

public function tools()
{
    return [
        // ...
        new NovaSettingsTool(),
        // ...
    ];
}


use WesLal\NovaSettingsTool\Enums\SettingType;
use WesLal\NovaSettingsTool\Events\SettingsRegistering;
use WesLal\NovaSettingsTool\ValueObjects\SettingGroup;
use WesLal\NovaSettingsTool\ValueObjects\SettingItem;

// ...

class SettingsRegisteringListener
{
    // ...
    public function handle(SettingsRegistering $event)
    {
        // ...
    }
    // ...
}


use WesLal\NovaSettingsTool\Events\SettingsRegistering;
use App\Handlers\SettingsRegisteringListener;

// ...

protected $listen = [
    // ...
    SettingsRegistering::class => [
        SettingsRegisteringListener::class
    ]
    // ...
];


public function handle(SettingsRegistering $event)
{
    $event->settingRegister
        ->group('general', function(SettingGroup $group) {
            $group->name('General')
                ->icon('fa fa-cog')
                ->item('title', function (SettingItem $item) {
                    $item->name('Website Title');
                })
                ->item('description', function (SettingItem $item) {
                    $item->type(SettingType::TEXTAREA);
                });
        })
        ->group('privacy', function(SettingGroup $group) {
            $group
                ->name('Privacy')
                ->icon('fa fa-user-secret')
                ->item('log', function (SettingItem $item) {
                    $item->name('Log User Activity')
                        ->field(Boolean::make('log')->help(
                            'When enabled, user activity will be logged.'
                        ));
                });
        });
}
bash
php artisan migrate
bash
php artisan vendor:publish --tag="settings"