PHP code example of vluzrmos / eloquent-settings

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

    

vluzrmos / eloquent-settings example snippets


use \Vluzrmos\EloquentSettings\Setting;

class YourInjectableClass {
   
   protected $settings;
   
   public function __construct (Setting $settings) {
       $this->settings = $settings;   
   }
   
   public function theMethod() {
       $option = $this->settings->get('my.awesome.option', 'default-value');
   }
} 
    

// Getter
$option = setting('my.awesome.option', 'default-value');
//or
$option = setting()->get('my.awesome.option', 'default-value');

// Setter
setting()->set('my.awesome.option', 'That is Awesome!');

setting()->save(); //remember, without this the settings will not be stored on database