The laravel settings package let you save your settings in the database and access them easily.
mjpakzad/laravel-settings is a Laravel package for the laravel settings package let you save your settings in the database and access them easily..
It currently has 1 GitHub stars and 3 downloads on Packagist (latest version v1.0.0).
Install it with composer require mjpakzad/laravel-settings.
Discover more Laravel packages by mjpakzad
or browse all Laravel packages to compare alternatives.
Last updated
The laravel settings package let you save your settings in the database and access them easily.
Add this package to your project using composer
composer require mjpakzad/laravel-settings
Publish the migration file
php artisan vendor:publish --provider="Mjpakzad\LaravelSettings\SettingServiceProvider"
Migrate the new migration to create settings table
php artisan migrate
Create a new setting
set_setting($key, $value, $group, $autoload)
You can group settings for example footer-settings or seo or anything else, default value of $group is null.
Also, you can autoload some settings to load in your AppServiceProvider, default value of $autoload is false.
examples
set_setting('site-name', 'Laravel settings')
set_setting('blog-title', 'My personal blog', 'blog', true)
Get a value by key
get_setting('site_name')
Get values by group
setting_group('blog')
Get autoload settings
setting_autoload($autoload)
default value of $autoload is true
Also, you can bring all settings out to config.
setting_config()
This function save all settings as key-value pairs in config, you can filter settings by parameters like below:
setting_config($keys, $groups, $autoload)
All parameters have null value.
Now, you can access them by config() method:
config('settings')