PHP code example of merodiro / settings

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

    

merodiro / settings example snippets


use Merodiro\Settings\HasSettings;

class User extends Model
{
    use HasSettings;
    ...
}

// Global Settings
Settings::set('key', 'value');
Settings::set('key', 'another value');

// User Settings
$user->setSettings('key', 'value');
$user->setSettings('key', 'another value');

// Global Settings
$name = Settings::get('site-name');
$value = Settings::get('key', 'default');

// User Settings
$user->getSettings('site-name');
$user->getSettings('key', 'value');

// Global Settings
Settings::forget('key');

// User Settings
$user->forgetSettings('key');

// Global Settings
Settings::flush();

// User Settings
$user->flushSettings();

// Global Settings
$settings = Settings::all();

// User Settings
$settings = $user->allSettings();

<h1>@settings('site-name')</h1>
<h1>@settings('site-name', 'default name')</h1>
bash
$ php artisan vendor:publish --provider=Merodiro\Settings\SettingsServiceProvider
bash
# Global settings only
php artisan settings:cache

# Global and User Settings
php artisan settings:cache --model=App/User
bash
# Global settings only
$ php artisan settings:clear

# Global and User Settings
$ php artisan settings:clear --model=App/User