PHP code example of netcore / module-setting

1. Go to this page and download the library: Download netcore/module-setting 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/ */

    

netcore / module-setting example snippets


    $settings = [
        [
            'group' => 'global',
            'name'  => 'Name',
            'key'   => 'key',
            'value' => 'value', // This will set this value to all languages
            // Or you can pass value as array and set different value in different language
            // 'value' => [
            //      'en' => 'value en',
            //      'lv' => 'value lv',
            // ],
            'type'  => 'select', // Available types: text, textarea, select, checkbox, file
            'meta'  => [
                // Here you can specify what HTML attributes you want for this input
                'attributes' => [
                    '   setting()->seed($settings);

    // Fetch setting by key
    setting()->get('global.key');
    
    // Optionally you can pass second parameter as the default value if the setting is not found
    setting()->get('global.key', 'default');
    
    // You can pass key variable as array to get multiple settings at once
    setting()->get(['global.one', 'global.two']);
    
    // Optionally you can pass second parameter as the default value as string or array and it will set defaults respectively
    setting()->get(['global.one', 'global.two'], ['default_one', 'default_two']);
    
    // Fetch all settings
    setting()->all();
    
    // Fetch grouped settings
    setting()->grouped();

    php artisan module:publish-config Setting
    php artisan module:publish-migration Setting
    php artisan migrate