1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-06 01:34:02 +00:00

Write test for extra config, fix bug with extra config

This commit is contained in:
Samuel Štancl 2020-05-03 17:27:37 +02:00
parent dfefe77793
commit bfa62a3f0c
3 changed files with 58 additions and 8 deletions

View file

@ -125,13 +125,18 @@ class DatabaseConfig
});
// Remove DB name because we set that separately
if (isset($dbConfig['_tenancy_db_name'])) {
unset($dbConfig['_tenancy_db_name']);
if (($pos = array_search('_tenancy_db_name', $dbConfig)) !== false) {
unset($dbConfig[$pos]);
}
// Remove DB connection because that's not used inside the array
if (($pos = array_search('_tenancy_db_connection', $dbConfig)) !== false) {
unset($dbConfig[$pos]);
}
return array_reduce($dbConfig, function ($config, $key) {
return array_merge($config, [
Str::substr($key, 0, strlen('_tenancy_db_')) => $this->tenant[$key],
Str::substr($key, strlen('_tenancy_db_')) => $this->tenant[$key],
]);
}, []);
}