Downloads
Stars
Version
Global key-value store in the database
https://github.com/appstract/laravel-options
To get started with laravel-options, use Composer to add the package to your project's dependencies:
composer require summergeorge/laravel-options ^6.0
By running php artisan vendor:publish --provider="Summergeorge\Options\OptionsServiceProvider"
in your project all files for this package will be published. For this package, it's only a migration. Run php artisan migrate
to migrate the table. There will now be an options
table in your database.
With the option()
helper, we can get and set options:
// Get option
option('someKey');
// Get option, with a default fallback value if the key doesn't exist
option('someKey', 'Some default value if the key is not found');
// Set option
option(['someKey' => 'someValue']);
// Remove option
option()->remove('someKey');
// Check the option exists
option_exists('someKey');
If you want to check if an option exists, you can use the facade:
use Option;
$check = Option::exists('someKey');
It is also possible to set options within the console:
php artisan option:set {someKey} {someValue}
$ composer test
The MIT License (MIT). Please see License File for more information.