PHP code example of pharaonic / laravel-settings

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

    

pharaonic / laravel-settings example snippets


use Pharaonic\Laravel\Settings\Concerns\HasSettings;

class Company extends Model
{
    use HasSettings;
}

settings()->setValue('site.name', 'Pharaonic');      // global, type string
settings('checkout')->setValue('minimum', 100);      // named scope, type integer
$company->setSetting('timezone', 'Africa/Cairo');    // model scope, written right away

settings()->getValue('site.name');                   // 'Pharaonic'
settings('checkout')->setValue('minimum', '100');    // SettingTypeMismatchException: stays an integer

$theme = settings($branch)
    ->fallbackTo($company)
    ->fallbackToGlobal()                             // then the global scope
    ->getValue('theme', 'light');

Setting::for($company)->where('type', 'string')->get(); // plain Eloquent: Setting models
bash
php artisan vendor:publish --tag=settings-config