The Laravel Settings Package has been developed to allow you to add general settings to your website in a simple and easy way, you can add settings for a specific model item as well, Let's start using it in simple steps. The Laravel Settings package requires Laravel 8+.
To install and setup the Laravel Settings we will follow a few steps:
Install via composer
composer require yazan/laravel-settings
php artisan vendor:publish --tag=settings
php artisan migrate
we will call the set method from the Setting class and set the key and value simply
$setting = \Setting::set('age', 18);
Here we retrieve data from Setting
$setting = \Setting::get('age'); // 18
we can set setting for specific item of Model as below
$user = User::find(1); $user->setSetting('age', 18);
Here we retrieve the Setting from model
$user->getSetting('age'); // 18
also, we can retrieve Setting as a group
$user->getSettingGroup('default'); //['age' => 18]
Here's the basic introduction of this package, If you want to learn more you can visit its complete documentation on Github.
Published at : 31-03-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.