Looking to hire Laravel developers? Try LaraJobs

laravel-settings maintained by mjpakzad

Description
The laravel settings package let you save your settings in the database and access them easily.
Author
Last update
2022/10/16 19:22 (dev-main)
License
Downloads
3

Comments
comments powered by Disqus

laravel-settings

The laravel settings package let you save your settings in the database and access them easily.

install

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

Usage

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