mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 02:44:02 +00:00
Initial draft
This commit is contained in:
parent
4ff82a950d
commit
5d7d208e2f
19 changed files with 376 additions and 186 deletions
|
|
@ -19,6 +19,7 @@ use Stancl\Tenancy\Exceptions\TenantStorageException;
|
|||
/**
|
||||
* @internal Class is subject to breaking changes in minor and patch versions.
|
||||
*/
|
||||
// todo make this class serializable
|
||||
class Tenant implements ArrayAccess
|
||||
{
|
||||
use Traits\HasArrayAccess,
|
||||
|
|
@ -91,8 +92,7 @@ class Tenant implements ArrayAccess
|
|||
}
|
||||
|
||||
/**
|
||||
* DO NOT CALL THIS METHOD FROM USERLAND. Used by storage
|
||||
* drivers to create persisted instances of Tenant.
|
||||
* Used by storage drivers to create persisted instances of Tenant.
|
||||
*
|
||||
* @param array $data
|
||||
* @return self
|
||||
|
|
@ -272,23 +272,13 @@ class Tenant implements ArrayAccess
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the tenant's database's name.
|
||||
* Get database config.
|
||||
*
|
||||
* @return string
|
||||
* @return DatabaseConfig
|
||||
*/
|
||||
public function getDatabaseName(): string
|
||||
public function database(): DatabaseConfig
|
||||
{
|
||||
return $this->data['_tenancy_db_name'] ?? ($this->config->get('tenancy.database.prefix') . $this->id . $this->config->get('tenancy.database.suffix'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tenant's database connection's name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConnectionName(): string
|
||||
{
|
||||
return $this->data['_tenancy_db_connection'] ?? 'tenant';
|
||||
return new DatabaseConfig($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue