laravel-settings maintained by unisharp
Description
Persistent settings manager for laravel, translations are supported.
Author
Last update
2018/07/02 02:02 (dev-master)
License
Downloads
70 496
Tags
Last update
2018/07/02 02:02
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2018/01/29 09:02
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2018/01/27 17:54
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2018/01/27 17:54
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2018/01/22 08:00
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2017/06/23 08:14
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2017/05/11 02:54
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
Last update
2017/05/11 02:54
License
Require
- php >=5.5.0
- illuminate/support >=5.0.0
- illuminate/database >=5.0.0
- illuminate/cache >=5.0.0
comments powered by Disqus
Persistent Settings Manager for Laravel
- Simple key-value storage
- Support multi-level array (dot delimited keys) structure.
- Localization supported.
Installation
-
Install package
composer require unisharp/laravel-settings
-
Edit config/app.php (Skip this step if you are using laravel 5.5+)
service provider:
Unisharp\Setting\SettingServiceProvider::class,
class aliases:
'Setting' => Unisharp\Setting\SettingFacade::class,
-
Create settings table
php artisan vendor:publish --tag=settings php artisan migrate
Usage
Setting::get('name', 'Computer');
// get setting value with key 'name'
// return 'Computer' if the key does not exists
Setting::all();
// get all settings
Setting::lang('zh-TW')->get('name', 'Computer');
// get setting value with key and language
Setting::set('name', 'Computer');
// set setting value by key
Setting::lang('zh-TW')->set('name', 'Computer');
// set setting value by key and language
Setting::has('name');
// check the key exists, return boolean
Setting::lang('zh-TW')->has('name');
// check the key exists by language, return boolean
Setting::forget('name');
// delete the setting by key
Setting::lang('zh-TW')->forget('name');
// delete the setting by key and language
Dealing with array
Setting::get('item');
// return null;
Setting::set('item', ['USB' => '8G', 'RAM' => '4G']);
Setting::get('item');
// return array(
// 'USB' => '8G',
// 'RAM' => '4G',
// );
Setting::get('item.USB');
// return '8G';
Dealing with locale
By default language parameter are being resets every set or get calls. You could disable that and set your own long term language parameter forever using any route service provider or other method.
Setting::lang(App::getLocale())->langResetting(false);