This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
You can install the package via composer:
composer require nzsakib/db-config
You can either use facade or direct implementation class to work.
// You can use following facade
\Nzsakib\DbConfig\Facades\CustomConfig::getCollection();
// Or you can use the implementation below
(new \Nzsakib\DbConfig\DbConfig())->getCollection();
use Nzsakib\DbConfig\DbConfig;
$config = new DbConfig;
$allConfig = $config->getCollection(); // returns Model collection of specified table
// pass to blade or do your thing by looping
foreach($allConfig as $config) {
dump($config->name);
dump($config->value);
}
use Nzsakib\DbConfig\DbConfig;
$config = new DbConfig;
$name = 'facebook';
$value = [
'client_id' => 'a client id',
'client_secret' => 'client secret',
];
// Value could be any data type e.g. boolean/array/string/integer
try {
$newConfig = $config->set($name, $value);
// new config is set and cache is invalidated
} catch (\InvalidArgumentException $e) {
// redirect with message $e->getMessage()
}
Cache will be deleted automatically after successfull update.
use Nzsakib\DbConfig\DbConfig;
use Illuminate\Database\Eloquent\ModelNotFoundException;
$config = new DbConfig;
$name = 'facebook';
$newValue = [
'client_id' => 'updated client id',
'client_secret' => 'updated secret'
];
try {
$updatedConfig = (new DbConfig)->updateByName($name, $newValue);
// Updated model is returned
} catch (ModelNotFoundException $e) {
// Specified name does not exists in database
}
// Or you could update by `id` which is primary key
try {
$updatedConfig = (new DbConfig)->updateById($id, $name, $newValue);
// Updated model is returned
} catch (ModelNotFoundException $e) {
// Specified id does not exists in database
}
Cache will be deleted automatically after successfull delete.
use Nzsakib\DbConfig\DbConfig;
use Illuminate\Database\Eloquent\ModelNotFoundException;
$name = 'facebook';
try {
$deletedConfig = (new DbConfig)->deleteByName($name);
// deleted successfully
} catch (ModelNotFoundException $e) {
// specified name does not exists in database
}
// Or delete the config by primary key `id`
$id = request('id');
try {
$deletedConfig = (new DbConfig)->deleteById($id);
// deleted successfully
} catch (ModelNotFoundException $e) {
// specified id does not exists in database
}
use Nzsakib\DbConfig\DbConfig;
$query = (new DbConfig)->getQuery();
// Returns Builder instance to underlying config table Model
// You can run custom query on it
$query->where('name', 'facebook')->delete();
// facebook config row is deleted from DB
php artisan vendor:publish --provider="Nzsakib\DbConfig\DbConfigServiceProvider" --tag="config"
php artisan vendor:publish --provider="Nzsakib\DbConfig\DbConfigServiceProvider" --tag="migrations"
You can change table name of the migration file, but make sure you mention the updated table name in the config file.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email sukku.mia@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.