PHP code example of vkovic / laravel-settings

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

    

vkovic / laravel-settings example snippets


// Set setting value as string
Settings::set('foo', 'bar');

// Get setting value
Settings::get('foo'); // : 'bar'

// In case there is no settings found for given key,
// we can pass default value to return
Settings::get('baz', 'default'); // : 'default'

Settings::set('computer.display.resolution', '1280x1024');
Settings::set('computer.display.brightness', 97);
Settings::set('computer.sound.volume', 54);
Settings::set('computer.mic.volume', 0);

Settings::query('computer.display.*');
// Result:
// [
//     'computer.display.resolution' => '1280x1024',
//     'computer.display.brightness' => 97
// ]

Settings::query('*.sound.*');
// Result:
// [
//     'computer.sound.volume' => 54
// ]

Settings::query('computer.*.volume');
// Result:
// [
//     'computer.sound.volume' => 54,
//     'computer.mic.volume' => 0
// ]

// In case there is no settings found for given query,
// we can pass default value to return
Settings::query('computer.sound.bass', 85); // : 85

Settings::set('age', 35);
Settings::set('temperature', 24.7);
Settings::set('value', null);
Settings::set('employed', true);
Settings::set('fruits', ['orange', 'apple']);

Settings::get('age'); // : 35
Settings::get('temperature'); // : 24.7
Settings::get('value', null); // : null
Settings::get('employed'); // : true
Settings::get('fruits'); // : ['orange', 'apple']

Settings::set('foo', 'bar');

Settings::exists('foo'); // : true

Settings::set('a', 'one');
Settings::set('b', 'two');

Settings::count(); // : 2

Settings::set('a', 'one');
Settings::set('b', 'two');
Settings::set('c', 'three');

// Get all settings
Settings::all(); // : ['a' => 'one', 'b' => 'two', 'c' => 'three']

// Get only keys
Settings::keys(); // : [0 => 'a', 1 => 'b', 2 => 'c']

Settings::set('a', 'one');
Settings::set('b', 'two');
Settings::set('c', 'three');

// Remove settings by key
Settings::remove('a');

// Or array of keys
Settings::remove(['b', 'c']);

// This will delete all settings!
Settings::purge();
bash
php artisan migrate