Package Data | |
---|---|
Maintainer Username: | tajul_asri |
Maintainer Contact: | mtajulasri@gmail.com (Tajul) |
Package Create Date: | 2016-11-07 |
Package Last Update: | 2017-03-17 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-18 03:04:03 |
Package Statistics | |
---|---|
Total Downloads: | 42 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 1 |
##Laravel 5 key value configurations using database
This package is for laravel cache learning purpose.Using laravel cache for creating config like wordpress which is stored on cache loaded from table config
installation
"tajul/lara-config" : "dev-master"
register laraconfig services provider
LaraConfig\LaraConfigServiceProvider::class,
LaraConfig\LaraConfigFacadeServiceProvider::class,
Register for facades alias
'LaraConfig' => LaraConfig\Facades\LaraConfigRepository::class,
publish vendor
php artisan vendor:publish --provider=LaraConfig\LaraConfigServiceProvider
publish vendor dirty ways
php artisan vendor:publish
run migration
php artisan migrate
Basic usage
use LaraConfig\LaraConfigRepository;
class ConfigController extends Controller
{
public function configRouteBind(LaraConfigRepository $config) {
$config->all();
}
}
Insert new Value
use LaraConfig\LaraConfigRepository;
class ConfigController extends Controller
{
public function configRouteBind(LaraConfigRepository $config) {
try
{
$config->set('key','value');
}
catch(Exception $e) {
return $e->getMessage();
}
}
}
get config by key
use LaraConfig\LaraConfigRepository;
class ConfigController extends Controller
{
public function configRouteBind(LaraConfigRepository $config) {
$config->get('key');
//if key are not exists return null
}
}
Or by using facades
use LaraConfig\LaraConfigRepository;
class ConfigController extends Controller
{
public function configRouteBind() {
\LaraConfig::all();
}
}
Available methods
//get all config key and values
\LaraConfig::all();
//get config value using key
\LaraConfig::get('key');
//set new config value using key
\LaraConfig::set('key','value);