PHP code example of sajadsdi / laravel-setting-pro

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

    

sajadsdi / laravel-setting-pro example snippets


// Get a setting value
$value = setting('my_setting')->get('key', 'default value');
//or 
$value = setting('my_setting','key', 'default value');
//or
$value = setting()->select('my_setting')->get('key', 'default value');


// Set a setting value
setting('my_setting')->set(['key' => 'value']);
//or
setting()->select('my_setting')->set(['key' => 'value']);


//delete a key from setting
setting('my_setting')->delete('key');
//or
setting()->select('my_setting')->delete('key');



use Sajadsdi\LaravelSettingPro\Support\Setting;

// Get a setting value
$value = Setting::select('my_setting')->get('key', 'default value');
//or
$value = Setting::my_setting()->get('key', 'default value');
//or
$value = Setting::my_setting('key', 'default value');

// Set a setting value
Setting::select('my_setting')->set('key', 'value');
//or
Setting::my_setting()->set('key', 'value');

//delete key from setting
Setting::select('my_setting')->delete('key');
//or
Setting::my_setting()->delete('key');

//checking exists by has method
if(Setting::select('my_setting')->has('key')){
    echo "key exists!";
}else{
    echo "key not exists!";
}


//get operation

$value = Setting::my_setting(['users.3.profile.pic','users.3.profile.name'], ["default.png","No name"]);
//or multi keys and single defaults
$value = setting('my_setting')->get(['users.3.profile.pic','users.3.profile.name'], ["no data"]);


//set operation 
setting::select('my_setting')->set(['users.3.profile.pic' => "profile.png",'users.3.profile.name' => "john"])

//delete multiple keys
setting::select('my_setting')->delete(['users.3.profile.pic','users.3.profile.name']);

//multiple keys checking exists by has method
if(Setting::select('my_setting')->has(['users.3.profile.pic','users.3.profile.name'])){
    echo "The keys are exists!";
}else{
    echo "The keys do not exist!";
}


// it's very Easy
bash
php artisan setting:publish
bash
php artisan setting:install
bash
php artisan setting:clear-cache