rogerarruda/laravel-options

Global options loaded from the database

1.2.1 2019-01-31 18:42 UTC

This package is auto-updated.

Last update: 2025-03-29 01:10:05 UTC


README

Latest Version on Packagist Total Downloads Software License Compatible with Laravel

Global key-value store in the database

Original Copyright(c) AppStract

Installation

You can install the package via composer:

composer require rogerarruda/laravel-options

Migrate

Run php artisan migrate to migrate the table. There will now be an options table in your database.

Usage

With the option() helper, we can get and set options:

// Get option
option('someKey');

// Set option
option(['someKey' => 'someValue']);

// Check the option exists
option_exists('someKey');

If you want to check if an option exists, you can use the facade:

use RogerArruda\LaravelOptions\Models\Option;

$check = Option::exists('someKey');

Setting a value to a key that already exists will overwrite the value.

Console

It is also possible to set options within the console:

php artisan option:set {someKey} {someValue}

Testing

$ composer test

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

The MIT License (MIT). Please see License File for more information.