weboap/option

Save and retreive config from db for laravel 5 / Access Config as Array

Installs: 125

Dependents: 0

Stars: 5

Watchers: 1

Forks: 1

Language: PHP

v2.0.2 2015-06-22 04:49 UTC

README

Save and retreive config from db for laravel / Access Config as Array

Laravel 4 users use "weboap/option": "v1.0.5"

Installation

The recommended way to install Winput is through composer.

Step 1

Just add to composer.json file:

{
    "require": {
        "weboap/option": "dev-master"
    }
}

then run

php composer.phar update

Step 2

Add

'Weboap\Option\OptionServiceProvider'

to the list of service providers in config/app.php

Step 3

Migrate the Option Table Run

php artisan vendor:publish
php artisan migrate

you can check app/option.php to costumize Option config file.

Usage

Note : the keys are to be set group.key (eg: 'gallery.path', 'cache.timeout') that way the options are grouped per categories keys that don't have a group the package will prepend 'global.' to eg: seting a key : 'business' will be retreived like 'global.business'


//set one key
Option::set('group.key', 'value');

// or set an array of key, values
Option::set(array('key0'=> 'value', 'group.key'=>'value', 'someothergroup.key1'=>'value1', .....));


Option::get('group.key');
Option::get('global.key');

Option::group('prefix'); // will return an array of options prefixed with group


Option::forget('group.key');

Option::has('group.key');

//retreive all keys, values at once
Option::all(); 




or


you can access config as array like


$config = App::make('option');

$config['mygroup.foo'] = 'bar';

echo $config['mygroup.foo'];

unset($config['mygroup.foo']);



Enjoy!