tuvaergun / l5-options by tuvaergun

Persistent Options Manager for Laravel 5
790
2
1
Package Data
Maintainer Username: tuvaergun
Maintainer Contact: web@tuva.me (Tuva Ergun)
Package Create Date: 2015-10-31
Package Last Update: 2015-10-31
Home Page: http://www.tuva.me
Language: PHP
License: MIT
Last Refreshed: 2024-12-14 15:01:40
Package Statistics
Total Downloads: 790
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Persistent Options Manager for Laravel 5

This package makes it easy to store persistent key/value options in your Laravel 5 application. All options are stored in your database and cached in a json file to minimize database queries.

Install it

To install this package include it in your composer.json and run composer update:

"require": {
   "tuvaergun/l5-options": "dev-master"
}
 

Add the Service Provider to the provider array in your config/app.php

'Tuva\Options\OptionsServiceProvider'

Add an alias for the facade to your config/app.php

'Options'  => 'Tuva\Options\Facades\Options',

Publish the config and migration files:

$ php artisan vendor:publish --provider="Tuva\Options\OptionsServiceProvider"

Change config/options.php according to your needs. If you change db_table, don't forget to change the table's name in the migration file as well.

Create the options table.

$ php artisan migrate

Use it

Set a value

Options::set('key', 'value');

Get a value

$value = Options::get('key');

Forget a value

Options::forget('key');

Forget all values

Options::flush();