PHP code example of salehye / laravel-settings

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

    

salehye / laravel-settings example snippets


// config/web-settings.php
return [
    'table_name' => 'web_settings',
    'cache' => [
        'enabled' => env('WEB_SETTINGS_CACHE_ENABLED', true),
        'duration' => env('WEB_SETTINGS_CACHE_DURATION', 60),
        'prefix' => env('WEB_SETTINGS_CACHE_PREFIX', 'web_settings_'),
    ],
    'validation' => [
        'rules' => [
            // 'app_name' => '_ENABLED', false),
        'locales' => ['en', 'ar'],
        'default_locale' => 'en',
    ],
];

// Using the Facade
use Salehye\LaravelSettings\Support\Facades\Settings;

$appName = Settings::get('app_name', 'Default App Name');

// Using the helper function
$contactEmail = web_setting('contact_email', '[email protected]');

// Get all settings
$allSettings = Settings::all();

// Using the Facade
Settings::set('app_name', 'My New App Name', 'string', 'general', 'Updated application name');

// Using the helper function (if you need to set, call without arguments first)
web_setting()->set('contact_email', '[email protected]', 'email', 'contact');

Settings::forget('old_setting_key');
bash
php artisan web-settings:install
bash
php artisan vendor:publish --provider="Salehye\LaravelSettings\Providers\Salehye\LaravelSettingsServiceProvider" --tag="web-settings-config"
php artisan vendor:publish --provider="Salehye\LaravelSettings\Providers\Salehye\LaravelSettingsServiceProvider" --tag="web-settings-migrations"
php artisan migrate