2017 © Pedro Peláez

library settings

Easy global/user settings



Easy global/user settings

  • Tuesday, April 10, 2018
  • by merodiro
  • Repository
  • 5 Watchers
  • 34 Stars
  • 660 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 24 % Grown



Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

laravel easy key => value global/user settings, (*2)


Via Composer, (*3)

``` bash $ composer require merodiro/settings, (*4)

publish config through Optional: only if you want to edit cache configurations ```bash $ php artisan vendor:publish --provider=Merodiro\Settings\SettingsServiceProvider

Setup a Model

use Merodiro\Settings\HasSettings;

class User extends Model
    use HasSettings;


Set settings

creates a record if the key doesn't exist or update it if the key exists, (*5)

in addition to updating the cache, (*6)

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

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

Get value from settings

Returns its value if it exists or the second parameter if it doesn't exist, (*7)

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

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

Delete key from settings

Remove the setting with the given key in addition to removing it from the cache, (*8)

// Global Settings

// User Settings

Delete all settings

Delete all the settings in addition to removing them from the cache, (*9)

// Global Settings

// User Settings

Get all settings

Returns all settings stored in key => value array, (*10)

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

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

Artisan Commands

Cache all settings

Caches all settings for the duration that has been set in settings.php config file, (*11)

you can set the duration to a high number or schedule the command to run often to get the best value of it, (*12)

# Global settings only
php artisan settings:cache

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

Clear cache for all settings

# Global settings only
$ php artisan settings:clear

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

Blade Directives

Get value from blade template

<h1>@settings('site-name', 'default name')</h1>


bash $ composer test, (*13)


Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*14)


If you discover any security-related issues, please email merodiro@gmail.com instead of using the issue tracker., (*15)



The MIT License (MIT). Please see License File for more information., (*16)

The Versions

23/12 2017

v0.1 https://github.com/Merodiro/Settings

Easy global settings

  Sources   Download


The Requires


The Development Requires

settings merodiro