PHP code example of rayhan2001 / laravel-settings-manager

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

    

rayhan2001 / laravel-settings-manager example snippets


return [
    App\Providers\AppServiceProvider::class,
    Rayhan\Settings\SettingsServiceProvider::class, // Add this line
];

// Get a setting value
$value = Settings::get('site_name');

// Set a setting value
Settings::set('site_name', 'My Awesome Site');

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

// Check if a setting exists
if (Settings::has('site_name')) {
    // Do something
}

// Get a setting value
$value = settings('site_name');

// Set a setting value
settings(['site_name' => 'My Awesome Site']);

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

use Rayhan\Settings\Services\SettingsManager;

class YourController extends Controller
{
    public function index(SettingsManager $settings)
    {
        $siteName = $settings->get('site_name');
        // ...
    }
}

'sections' => [
    'general' => [
        // ...
    ],
    'custom' => [
        'title' => 'Custom Section',
        'icon' => 'bi-star',
        'fields' => [
            [
                'type' => 'text',
                'label' => 'Custom Field',
                'key' => 'custom_field',
                'placeholder' => 'Enter custom value',
                'rules' => 'nullable|string|max:255',
            ],
        ],
    ],
],
bash
composer dump-autoload
bash
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider"
bash
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=migrations
bash
php artisan vendor:publish --provider="Rayhan\Settings\SettingsServiceProvider" --tag=views
bash
php artisan migrate