DatabaseManager
class DatabaseManager (View source)
Properties
string | $originalDefaultConnectionName | ||
protected Application | $app | ||
protected DatabaseManager | $database | ||
protected TenantManager | $tenancy |
Methods
No description
Set the TenantManager instance, used to dispatch tenancy events.
Reconnect to the default non-tenant connection.
Change the default database connection config.
Create the tenant database connection.
Get the name of the connection that $connectionName should be based on.
Get the driver of a database connection.
Switch the application's connection.
Get the TenantDatabaseManager for a tenant's database connection.
What key on the connection config should be used to separate tenants.
Details
__construct(Application $app, DatabaseManager $database)
No description
DatabaseManager
withTenantManager(TenantManager $tenantManager)
Set the TenantManager instance, used to dispatch tenancy events.
void
connect(Tenant $tenant)
Connect to a tenant's database.
void
reconnect()
Reconnect to the default non-tenant connection.
void
setDefaultConnection(string $connection)
Change the default database connection config.
void
createTenantConnection(string $databaseName, string $connectionName)
Create the tenant database connection.
string
getBaseConnection(string $connectionName)
Get the name of the connection that $connectionName should be based on.
string|null
getDriver(string $connectionName)
Get the driver of a database connection.
void
switchConnection(string $connection)
Switch the application's connection.
void
ensureTenantCanBeCreated(Tenant $tenant)
Check if a tenant can be created.
void
createDatabase(Tenant $tenant, array $afterCreating = [])
Create a database for a tenant.
void
deleteDatabase(Tenant $tenant)
Delete a tenant's database.
TenantDatabaseManager
getTenantDatabaseManager(Tenant $tenant)
Get the TenantDatabaseManager for a tenant's database connection.
string
separateBy(string $connectionName)
What key on the connection config should be used to separate tenants.