appstract / laravel-options by gizburdt

Global options loaded from the database
301,313
719
19
Package Data
Maintainer Username: gizburdt
Maintainer Contact: gijs@appstract.nl (Gijs Jorissen)
Package Create Date: 2017-03-02
Package Last Update: 2024-04-17
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-05-02 15:01:55
Package Statistics
Total Downloads: 301,313
Monthly Downloads: 7,001
Daily Downloads: 285
Total Stars: 719
Total Watchers: 19
Total Forks: 66
Total Open Issues: 2

Laravel Options

Latest Version on Packagist Total Downloads Software License Build Status

Global key-value store in the database

Installation

You can install the package via composer:

composer require appstract/laravel-options

Publish, migrate

By running php artisan vendor:publish --provider="Appstract\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.

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 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.