Tenant
class Tenant implements ArrayAccess (View source)
internal | Class is subject to breaking changes in minor and patch versions. |
Traits
Properties
array | $data | Tenant data. A "cache" of tenant storage. |
|
string[] | $domains | List of domains that belong to the tenant. |
|
protected Repository | $config | ||
protected StorageDriver|CanDeleteKeys | $storage | ||
protected TenantManager | $manager | ||
protected UniqueIdentifierGenerator | $idGenerator | ||
bool | $persisted | Does this tenant exist in the storage. |
Methods
Use new() if you don't want to swap dependencies.
DO NOT CALL THIS METHOD FROM USERLAND. Used by storage drivers to create persisted instances of Tenant.
DO NOT CALL THIS METHOD FROM USERLAND UNLESS YOU KNOW WHAT YOU ARE DOING.
Does this model exist in the tenant storage.
Assign domains to the tenant.
Unassign domains from the tenant.
Unassign all domains from the tenant.
Set (overwrite) the tenant's domains.
Generate a random ID.
Unassign all domains from the tenant and write to storage.
Get the tenant's database's name.
Get the tenant's database connection's name.
Get a value from tenant storage.
Delete keys from the tenant's storage.
No description
No description
No description
Details
bool
offsetExists($offset)
No description
offsetGet($offset)
No description
void
offsetSet($offset, $value)
No description
void
offsetUnset($offset)
No description
__construct(Repository $config, StorageDriver $storage, TenantManager $tenantManager, UniqueIdentifierGenerator $idGenerator)
Use new() if you don't want to swap dependencies.
static Tenant
new(Application $app = null)
Public constructor.
static Tenant
fromStorage(array $data)
DO NOT CALL THIS METHOD FROM USERLAND. Used by storage drivers to create persisted instances of Tenant.
static Tenant
create(string|string[] $domains, array $data = [])
Create a tenant in a single call.
Tenant
persisted(bool $persisted)
DO NOT CALL THIS METHOD FROM USERLAND UNLESS YOU KNOW WHAT YOU ARE DOING.
Set $persisted.
bool
isPersisted()
Does this model exist in the tenant storage.
Tenant
addDomains(string|string[] $domains)
Assign domains to the tenant.
Tenant
removeDomains(string|string[] $domains)
Unassign domains from the tenant.
Tenant
clearDomains()
Unassign all domains from the tenant.
Tenant
withDomains(string|string[] $domains)
Set (overwrite) the tenant's domains.
Tenant
withData(array $data)
Set (overwrite) tenant data.
void
generateId()
Generate a random ID.
Tenant
save()
Write the tenant's state to storage.
Tenant
delete()
Delete a tenant from storage.
Tenant
softDelete()
Unassign all domains from the tenant and write to storage.
string
getDatabaseName()
Get the tenant's database's name.
string
getConnectionName()
Get the tenant's database connection's name.
void
get(string|string[] $keys)
Get a value from tenant storage.
Tenant
put(string|array<string,mixed> $key, mixed $value = null)
Set a value and write to storage.
Tenant
set($key, $value = null)
No description
Tenant
deleteKey(string $key)
Delete a key from the tenant's storage.
Tenant
deleteKeys(array $keys)
Delete keys from the tenant's storage.
Tenant
with(string $key, mixed $value)
Set a value in the data array without saving into storage.
mixed
run(Closure $closure)
Run a closure inside the tenant's environment.
__get($key)
No description
__set($key, $value)
No description
__call($method, $parameters)
No description