Skip to content

Instantly share code, notes, and snippets.

@morloderex
Created March 26, 2020 19:56
Show Gist options
  • Save morloderex/1fcb7cb7473b09a2698fe86bcad1be8e to your computer and use it in GitHub Desktop.
Save morloderex/1fcb7cb7473b09a2698fe86bcad1be8e to your computer and use it in GitHub Desktop.
Poposal
public function createTenantConnection(Tenant $tenant)
{
$tenantManager = $this->getTenantManager($tenant);
// Create the database connection.
$based_on = $this->getBaseConnection($connectionName);
$currentConfig = $this->app['config']['database.connections.' . $based_on];
$mergedConfig = array_replace($currentConfig, $tenantManager->createTenantConnection($tenant, $currentConfig) ?? []);
$this->app['config']['database.connection.' . $tenant->getConnectionName()] = $mergedConfig;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment