PHP code example of zahidhassanshaikot / settings

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

    

zahidhassanshaikot / settings example snippets


return [
    'cache' => [
        'enabled' => true,
    ],
];

use zahidhassanshaikot\Settings\Facades\Settings;

Settings::all();
Settings::updateOrCreate('site_name', 'laravel-settings');
Settings::updateOrCreateMultiple(['site_name' => 'laravel-settings', 'timezone' => 'UTC']);
Settings::get('site_name');
Settings::get('missing_key', 'a default value');
Settings::delete('site_name');


settings('site_name');
settings('missing_key', 'a default value');
settings(); // same as Settings::all()

Settings::updateOrCreate('maintenance_mode', true);
Settings::updateOrCreate('max_attempts', 5);
Settings::updateOrCreate('allowed_ips', ['127.0.0.1', '10.0.0.1']);

Settings::get('maintenance_mode'); // true
Settings::get('max_attempts');     // 5
Settings::get('allowed_ips');      // ['127.0.0.1', '10.0.0.1']
bash
php artisan vendor:publish --tag="settings-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="settings-config"
bash)

[//]: # (php artisan vendor:publish --tag="settings-views")

[//]: # (
bash
php artisan settings:list
php artisan settings:set {key} {value}
php artisan settings:forget {key}