1. Go to this page and download the library: Download jomigomes/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/ */
use JomiGomes\LaravelSettings\Facades\Settings;
// Or use the model directly:
// use JomiGomes\LaravelSettings\Models\Setting;
// Get a setting
$setting = Settings::get('features.enable_notifications', 'system');
// Set a setting
Settings::set('features.enable_notifications', false, 'system');
// Get all settings for a scope
$allSettings = Settings::getAllScoped('system');
// Get filtered settings
$features = Settings::getFiltered('system', 'features');
use JomiGomes\LaravelSettings\Traits\HasSettings;
class User extends Model
{
use HasSettings;
}
$user = User::find(1);
// Get a setting
$theme = $user->getSetting('preferences.theme');
// Set a setting
$user->setSetting('preferences.theme', 'dark');
// Get all settings
$allSettings = $user->getAllSettings();
// Get filtered settings
$preferences = $user->getFilteredSettings('preferences');