Tenant-aware Laravel settings package
You can install the package via composer:
composer require osenco/laravel-settingsYou can publish the config file with:
php artisan vendor:publish --tag="laravel-settings-config"You can publish and run the migrations with:
php artisan vendor:publish --tag="laravel-settings-migrations" && php artisan migrateThis is the contents of the published config file:
return [
// Define your global settings here
'global' => [
// 'setting_key' => 'default_value',
],
// Define your tenant-specific settings here
'tenant' => [
// 'setting_key' => 'default_value',
],
];To set a tenant-specific setting:
tenant('setting_key', 'value');To get a tenant-specific setting:
tenant('setting_key'); // Returns 'value'If a tenant-specific setting is not found, it will fall back to the global setting if available.
To set a global setting:
global_settings('setting_key', 'value');To get a global setting:
global_settings('setting_key'); // Returns 'value'You can also use the settings() helper function:
// Set a tenant-specific setting
settings()->tenant()->set('setting_key', 'value');
// Get a tenant-specific setting
settings()->tenant()->get('setting_key');
// Set a global setting
settings()->global()->set('setting_key', 'value');
// Get a global setting
settings()->global()->get('setting_key');composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.