PHP code example of ahmedash95 / laravel-settings

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

    

ahmedash95 / laravel-settings example snippets


Krucas\Settings\Providers\SettingsServiceProvider::class,

'Settings' => Krucas\Settings\Facades\Settings::class

Settings::set($key, $value = null);

Settings::get($key, $default = null);

Settings::has($key);

Settings::forget($key);

Settings::context(new Context(['user' => 1]));

$userContext1 = new Context(['user' => 1]);
$userContext2 = new Context(['user' => 2]);
Settings::context($userContext1)->set('key', 'value1');
Settings::context($userContext2)->set('key', 'value2');

// retrieve settings
$userValue1 = Settings::context($userContext1)->get('key'); // value1
$userValue2 = Settings::context($userContext2)->get('key'); // value2

settings();

settings([$key => $value]);

settings([$key => $value], new Context(['user' => 1]));

settings($key, $default = null);

settings($key, $default, new Context(['user' => 1]));
app/config/app.php

$ php artisan settings:table