Skip to content

Persistent key-value storage for Laravel, json value supported. l10n supported.

License

Notifications You must be signed in to change notification settings

gavinhewitt/laravel-settings

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Persistent Settings Manager for Laravel

  • Simple key-value storage
  • Support multi-level array (dot delimited keys) structure.
  • Localization supported.

Installation

  1. install package

    	composer require unisharp/laravel-settings
  2. edit config/app.php

    service provider :

    	Unisharp\Setting\SettingServiceProvider::class,

    class aliases :

    	'Setting' => Unisharp\Setting\SettingFacade::class,
  3. 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::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';

About

Persistent key-value storage for Laravel, json value supported. l10n supported.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%