LaravelPackages.net
Acme Inc.
Toggle sidebar
emresari89/laravel-options

Global options loaded from the database

125
0
v1.2.1
About emresari89/laravel-options

emresari89/laravel-options is a Laravel package for global options loaded from the database. It currently has 0 GitHub stars and 125 downloads on Packagist (latest version v1.2.1). Install it with composer require emresari89/laravel-options. Discover more Laravel packages by emresari89 or browse all Laravel packages to compare alternatives.

Last updated

Laravel Options

Latest Version on Packagist Total Downloads Software License Build Status

Global key-value store in the database

Installation

To get started with laravel-options, use Composer to add the package to your project's dependencies:

composer require emresari89/laravel-options

Publish, migrate

By running php artisan vendor:publish --provider="Emresari\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 all options 
options();

// Get option by id
optionID($id);

// 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']);

// Set option with type (type 1 default)
option_type(['someKey' => 'someValue'],null,2);

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

Console

It is also possible to set options within the console:

php artisan option:set {someKey} {someValue}

Testing

$ composer test

License

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

Comments