PHP code example of solomon-ochepa / laravel-settings

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

    

solomon-ochepa / laravel-settings example snippets


'providers' => [
    //...
    Oki\Settings\SettingsServiceProvider::class
]

'aliases' => [
    //...
    "Settings" => Oki\Settings\Facades\Settings::class
]

settings();
// or
settings()->all($fresh = false);
// or
Settings::all($fresh = false);

settings($key, $default = null);
// or
settings()->get($key, $default = null);
// or
Settings::get($key, $default = null);

settings()->my($key, $default = null);
// or
Settings::my($key, $default = null);

settings([$key => $value]);
// or
settings()->set($key, $value);
// or
Settings::set($key, $value);

settings([$key => $value, $key2 => $value2]);
// or
settings()->set([
   $key => $value,
   $key2 => $value2,
]);
// or
Settings::set([
   $key => $value,
   $key2 => $value2,
]);

settings()->has($key);
// or
Settings::has($key);

settings()->remove($key);
// or
Settings::remove($key);

// Save setting
settings([$key => $value])->group($name);

// Get setting
settings($key)->group($name);

Settings::for($settable_type, $settable_id = null)->set($key, $value)
// or
Settings::set($key, $value = null, $settable_type = null, $settable_id = null)

// helper function
settings()->for($settable_type = null, $settable_id = null)->set($key, $value = null)
// or
settings()->set($key, $value = null, $settable_type = null, $settable_id = null)

// Example:
settings()->for(User::class, auth()->id())->set('theme_mode', 'dark');

settings()->user()->all();

php artisan vendor:publish --provider="Oki\Settings\SettingsServiceProvider" --tag="migrations"