PHP code example of jpmanson / laravel-settings

1. Go to this page and download the library: Download jpmanson/laravel-settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jpmanson / laravel-settings example snippets


		composer 

		Unisharp\Setting\SettingServiceProvider::class,
	

		'Setting' => Unisharp\Setting\SettingFacade::class,
	

		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';