This is a simple way to manage user settings. The settings will be based on the configuration file and then stored within a json field in the users table.
You can install the package via composer:
composer require digitalion/laravel-simple-user-settings
Once installed you can publish the configuration file with:
php artisan vendor:publish --tag="laravel-simple-user-settings-config"
The configuration file will be empty, but you can fill it with any settings your app offers.
Right after that you will need to add the settings
field to the users
table.
php artisan migrate
Optionally, you can publish the migration to make any changes with:
php artisan vendor:publish --tag="laravel-simple-user-settings-migrations"
The package will offer you the settings
helper with which you can directly access user settings.
With the settings()
command you will get the array of all settings. If the user has no saved settings, all the basic values will be returned.
To read a given settings value you will have to use the settings('key')
command.
To get a nested value, use the dot as a separator. For example: settings('key1.key2.key3')
.
The values can be set with the command: settings('key', 'value')
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.