Download the PHP package sewidan/laravel-setting without Composer
On this page you can find all versions of the php package sewidan/laravel-setting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sewidan/laravel-setting
More information about sewidan/laravel-setting
Files in sewidan/laravel-setting
Package laravel-setting
Short Description Laravel Settings Manager
License MIT
Homepage https://github.com/MostafaSewidan/laravel-setting
Informations about the package laravel-setting
Advanced Settings Manager for Laravel
- Simple key-value storage
- Optional config file for default settings supported
- Support multi-level array (dot delimited keys) structure
- Supports storing individual user settings
- Localization supported
- Settings are cached
Installation
Via Composer
Publish config and migration
Setup your settings config
After publishing the setting files you will find a new configuration file: config/setting.php In this config you can define your basic settings like below.
You can also use multi level arrays
Defining optional config values
If you want to store additional data for a particular setting you can do so using an array and name one of the parameters 'default_value' which will be the default for the setting and is what gets returned by Settings::get('app_name') in this case.
Get full structure with default_value keys
By suffixing your key name with a dot or by using the Setting::getWithDefaultSubKeys('app_name')
method will return all default parameters including the current value
Scoped settings
You might want to save some settings only for a certain user. You can do this using a placeholder (_*) inside your config key name.
Set save the new setting on runtime:
Now you can get the value:
The above will return null if the setting does not exist for this user. In order to return something else you can set a default as the second parameter:
Get only the changed user settings
In order to get all user settings you can use the getWithDefaultSubKeys()
method or suffix the main key with a dot. The result will return a merged array with the default values from and the config while the changed values from the database will overwrite the default values.
Usage
Dealing with locale
By default language parameter are being resets every set or get calls. You could disable that and set your own long term language parameter forever using any route service provider or other method.
Custom Setting Model
The Setting model can be overwritten by creating a /config/laravel-setting.php config and adding:
Your custom model needs to extend the \JanisKelemen\Setting\EloquentStorage class.
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details.
Security
If you discover any security related issues, please send me a DM on Twitter @janiskelemen instead of using the issue tracker.
Credits
This package is mostly a fork of UniSharp/laravel-settings
- HelpSpace.io
- Janis Kelemen
- All Contributors
License
MIT. Please see the license file for more information.