Package Data | |
---|---|
Maintainer Username: | jpmanson |
Maintainer Contact: | service@unisharp.com (Unisharp Ltd.) |
Package Create Date: | 2016-05-30 |
Package Last Update: | 2016-06-07 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:03:46 |
Package Statistics | |
---|---|
Total Downloads: | 16 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
install package
composer require jpmanson/laravel-settings
edit config/app.php
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
Setting::get('name', 'Computer');
// get setting value with key 'name'
// return 'Computer' if the key does not exists
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
Setting::get('name', 'Computer', true);
// get setting value with key 'name'
// return 'Computer' if the key does not exists and save the key in database
// third parameter = true force to save the key with the provided default value if not exists
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';