class DatabaseManager (View source)

Properties

string $originalDefaultConnectionName
protected Application $app
protected DatabaseManager $database
protected TenantManager $tenancy

Methods

__construct(Application $app, DatabaseManager $database)

No description

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.

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.

Details

__construct(Application $app, DatabaseManager $database)

No description

Parameters

Application $app
DatabaseManager $database

DatabaseManager withTenantManager(TenantManager $tenantManager)

Set the TenantManager instance, used to dispatch tenancy events.

Parameters

TenantManager $tenantManager

Return Value

DatabaseManager

void connect(Tenant $tenant)

Connect to a tenant's database.

Parameters

Tenant $tenant

Return Value

void

void reconnect()

Reconnect to the default non-tenant connection.

Return Value

void

void setDefaultConnection(string $connection)

Change the default database connection config.

Parameters

string $connection

Return Value

void

void createTenantConnection(string $databaseName, string $connectionName)

Create the tenant database connection.

Parameters

string $databaseName
string $connectionName

Return Value

void

string getBaseConnection(string $connectionName)

Get the name of the connection that $connectionName should be based on.

Parameters

string $connectionName

Return Value

string

string|null getDriver(string $connectionName)

Get the driver of a database connection.

Parameters

string $connectionName

Return Value

string|null

void switchConnection(string $connection)

Switch the application's connection.

Parameters

string $connection

Return Value

void

void ensureTenantCanBeCreated(Tenant $tenant)

Check if a tenant can be created.

void createDatabase(Tenant $tenant, array $afterCreating = [])

Create a database for a tenant.

Parameters

Tenant $tenant
array $afterCreating

Return Value

void

Exceptions

DatabaseManagerNotRegisteredException

void deleteDatabase(Tenant $tenant)

Delete a tenant's database.

Parameters

Tenant $tenant

Return Value

void

Exceptions

DatabaseManagerNotRegisteredException

TenantDatabaseManager getTenantDatabaseManager(Tenant $tenant)

Get the TenantDatabaseManager for a tenant's database connection.

Parameters

Tenant $tenant

Return Value

TenantDatabaseManager

Exceptions

DatabaseManagerNotRegisteredException

string separateBy(string $connectionName)

What key on the connection config should be used to separate tenants.

Parameters

string $connectionName

Return Value

string