zahidhassanshaikot/settings is a Laravel package for this is my package settings.
It currently has 7 GitHub stars and 222 downloads on Packagist (latest version v2.1).
Install it with composer require zahidhassanshaikot/settings.
Discover more Laravel packages by zahidhassanshaikot
or browse all Laravel packages to compare alternatives.
Last updated
This package allows you to store settings in a database. The settings are cached to prevent queries to the database. If you update a setting it will be stored in the database and the cache will be flushed. This package is for managing most basic settings in your laravel application like site title, site logo etc. You can add your custom settings using this package.
If you find this project helpful or appreciate my work, please consider buying me a coffee! ☕️
You can install the package via composer:
composer require zahidhassanshaikot/settings
You can publish and run the migrations with:
php artisan vendor:publish --tag="settings-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="settings-config"
This is the contents of the published config file:
return [
'cache' => [
'enabled' => true,
],
];
You can use the facade for shorter code. Add the following to your facades:
use zahidhassanshaikot\Settings\Facades\Settings;
Settings::all();
Settings::updateOrCreate('site_name', 'laravel-settings');
Settings::updateOrCreateMultiple(['site_name' => 'laravel-settings', 'timezone' => 'UTC']);
Settings::get('site_name');
Settings::get('missing_key', 'a default value');
Settings::delete('site_name');
A global settings() helper is also available as shorthand for the facade:
settings('site_name');
settings('missing_key', 'a default value');
settings(); // same as Settings::all()
Values are no longer limited to strings. Booleans, integers, arrays, and other JSON-serializable values are stored and returned as their original type:
Settings::updateOrCreate('maintenance_mode', true);
Settings::updateOrCreate('max_attempts', 5);
Settings::updateOrCreate('allowed_ips', ['127.0.0.1', '10.0.0.1']);
Settings::get('maintenance_mode'); // true
Settings::get('max_attempts'); // 5
Settings::get('allowed_ips'); // ['127.0.0.1', '10.0.0.1']
Existing plain-string values written before this feature was added continue to work unchanged.
php artisan settings:list
php artisan settings:set {key} {value}
php artisan settings:forget {key}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.