Working on improved configuration and automatically destroy cart on user logout

This commit is contained in:
Rob Gloudemans
2016-08-03 19:41:35 +02:00
parent e07d08ca9b
commit 71cb7ce694
4 changed files with 74 additions and 3 deletions

View File

@@ -493,7 +493,9 @@ class Cart
*/
private function getConnection()
{
return app(DatabaseManager::class)->connection(config('cart.database.connection', config('database.default')));
$connectionName = $this->getConnectionName();
return app(DatabaseManager::class)->connection($connectionName);
}
/**
@@ -505,4 +507,16 @@ class Cart
{
return config('cart.database.table', 'shoppingcart');
}
/**
* Get the database connection name.
*
* @return string
*/
private function getConnectionName()
{
$connection = config('cart.database.connection');
return is_null($connection) ? config('database.default') : $connection;
}
}