PHP code example of aries / laravelsetting

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

    

aries / laravelsetting example snippets


'providers' => [
    ....
    Aries\LaravelSetting\LaravelSettingServiceProvider::class,
]

'aliases' => [
    ...
    'Setting' => Aries\LaravelSetting\Facade\Setting::class,
]

php artisan vendor:publish

php artisan migrate


namespace App\Http\Controllers;

use Aries\LaravelSetting\Facade\Setting;

class SettingController extends Controller {
    public function index(){
        #Set Primary Key :
        Setting::set('key', 'value', true);
    
        #Set a Setting property:
        Setting::set('key', 'value', false, false);
        
        #Get a Stored Setting value or pass default value
        $setting['key'] = Setting::get('key', 'default value');
        
        
        #Get All primary Keys
        $settings = Setting::getPrimary();
    }
    
    public function store(\Request $request){
        #get all settings from an key-value array and store them to database
        #example: <input type="text" name="setting['title']">
        Setting::store($request->input('setting'));
    }
}