Skip to content

osenco/laravel-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laravel-settings

Tenant-aware Laravel settings package

Installation

You can install the package via composer:

composer require osenco/laravel-settings

You 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 migrate

This 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',
    ],
];

Usage

Tenant Settings

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.

Global Settings

To set a global setting:

global_settings('setting_key', 'value');

To get a global setting:

global_settings('setting_key'); // Returns 'value'

Helper Function

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');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Tenant-aware Laravel settings package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages