Package Data | |
---|---|
Maintainer Username: | laravel-backbone |
Maintainer Contact: | author@laravelbackbone.com (Laravel Backbone) |
Package Create Date: | 2020-06-28 |
Package Last Update: | 2021-06-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-04-14 15:01:00 |
Package Statistics | |
---|---|
Total Downloads: | 14 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Easy Persistent Settings Management for Laravel.
Settings is a Laravel package. You can install it via Composer. Run this command in your terminal from your project directory:
composer require laravel-backbone/settings
Now run this command in your terminal to publish this package resources:
php artisan vendor:publish --provider="LaravelBackbone\Settings\Providers\SettingsServiceProvider"
If you run vendor:publish
then you have to add below code in your settings model
protected $table = 'lb_settings'; // you can change your database table name.
public $timestamps = false;
Use GetSettings
traits in your settings model.
For getting all settings value paired by key you can use all
method.
YourSettingModel::all(); // return collection
For set value you can use set
method.
YourSettingModel::set('key', 'value'); // return null
Multiple data store by key
YourSettingModel::set(['key1' => 'value', 'key2' => ['subkey2' => 'value-of-subkey2'] ]); // return null
For get value you can use get
method.
YourSettingModel::get('key'); // return collection or string or null
Fallback Support:
YourSettingModel::get('key2.subkey2'); // return collection or string or null
You can also get all setting value
YourSettingModel::get(); // return collection
For checking key exists or not you can use has
method.
YourSettingModel::has('key'); // return bool
Multiple key Forget:
YourSettingModel::has(['key1', 'key2']); // return collection
For delete key you can use forget
method.
YourSettingModel::forget('key'); // return integer 0 or 1
Multiple key Forget:
YourSettingModel::forget(['key1', 'key2']); // return integer - how many key successfully delete.
Get / set the specified setting value. If an array is passed as the key, we will assume you want to set an array of values.
$value = settings('app.timezone');
$value = settings('app.timezone', $default);
You may set settings variables by passing an array of key / value pairs:
settings(['app.debug' => true]);