outerweb / settings
This package adds application wide settings stored in your database.
Installs: 19 590
Dependents: 2
Suggesters: 0
Security: 0
Stars: 30
Watchers: 0
Forks: 1
Open Issues: 1
Requires
- php: ^8.0
- laravel/framework: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.16
README
This package adds application wide settings stored in your database.
Installation
You can install the package via composer:
composer require outerweb/settings
Run the install command:
php artisan settings:install
Usage
Saving settings
You can save settings using the helper function setting()
:
setting(['key' => 'value']);
You can also save multiple settings at once:
setting([ 'general.key1' => 'value1', 'general.key2' => 'value2', ]); // Returns [ 'general.key1' => 'value1', 'general.key2' => 'value2', ]
Retrieving settings
You can retrieve settings using the helper function setting()
:
setting(string $key, mixed $default = null); // Example setting('key', 'default'); // Returns 'value' // or 'default' if the key does not exist
The key can be a dot-notation key to retrieve nested settings:
setting('general.key1'); // Returns 'value1'
If you have multiple settings with the same parent key, you can retrieve them all at once:
setting('general'); // Returns [ 'key1' => 'value1', 'key2' => 'value2', ]
You can also retrieve all settings at once:
setting('*'); // Returns [ 'key' => 'value', 'general' => [ 'key1' => 'value1', 'key2' => 'value2', ], ]
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.