PHP code example of laraeast / laravel-settings

1. Go to this page and download the library: Download laraeast/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/ */

    

laraeast / laravel-settings example snippets


    Laraeast\LaravelSettings\Providers\SettingsServiceProvider::class,
    

    'Settings' => Laraeast\LaravelSettings\Facades\Settings::class,
    

Settings::get('name', 'Computer');
// get setting value with key 'name'
// return 'Computer' if the key does not exists

Settings::locale('en')->get('name', 'Computer');
// get setting value with key and language
 
Settings::get('name:en', 'Computer');
// get setting value with key and language
 
Settings::set('name', 'Computer');
// set setting value by key
 
Settings::locale('en')->set('name', 'Computer');
// set setting value by key and language
 
Settings::set('name:en', 'Computer');
// set setting value by key and language
 
Settings::has('name');
// check the key exists, return boolean
 
Settings::locale('en')->has('name');
// check the key exists by language, return boolean
 
Settings::has('name:en');
// check the key exists by language, return boolean
 
Settings::delete('name');
// delete the setting by key
 
Settings::locale('en')->delete('name');
// delete the setting by key and language
 
Settings::delete('name:en');
// delete the setting by key and language

Settings::get('item');
// return null;
 
Settings::set('item', ['USB' => '8G', 'RAM' => '4G']);
Settings::get('item');
// return array(
//     'USB' => '8G',
//     'RAM' => '4G',
// );

Settings::locale('en')->set('title', 'Example Website');
 
Settings::locale('en')->get('title');
// return return 'Example Website';
 
Settings::set('title:ar', 'عنوان الموقع');

Settings::locale('ar')->get('title');
// return return 'عنوان الموقع';

Settings::locale('ar')->has('title') // bool
Settings::locale('ar')->delete('title') 

App::setLocale('en');

Settings::locale()->get('title');
// return return 'Example Website';

$this->app['settings.manager']->extend('file', function () {
	return new SettingsFileDriverHandler();
});
bash
    php artisan settings:table
    php artisan migrate
    



namespace App\LaravelSettings;

use Laraeast\LaravelSettings\Contracts\SettingsStore;

class SettingsFileDriverHandler implements SettingsStore
{
    ...
}