class Tenant implements ArrayAccess (View source)

internal  Class is subject to breaking changes in minor and patch versions.
 

Traits

ForwardsCalls

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

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.

persisted(bool $persisted)

DO NOT CALL THIS METHOD FROM USERLAND UNLESS YOU KNOW WHAT YOU ARE DOING.

bool
isPersisted()

Does this model exist in the tenant storage.

addDomains(string|string[] $domains)

Assign domains to the tenant.

removeDomains(string|string[] $domains)

Unassign domains from the tenant.

clearDomains()

Unassign all domains from the tenant.

withDomains(string|string[] $domains)

Set (overwrite) the tenant's domains.

withData(array $data)

Set (overwrite) tenant data.

void
generateId()

Generate a random ID.

save()

Write the tenant's state to storage.

delete()

Delete a tenant from storage.

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.

put(string|array<string,mixed> $key, mixed $value = null)

Set a value and write to storage.

set($key, $value = null)

No description

deleteKey(string $key)

Delete a key from the tenant's storage.

deleteKeys(array $keys)

Delete keys from the tenant's storage.

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

Details

bool offsetExists($offset)

No description

Parameters

$offset

Return Value

bool

offsetGet($offset)

No description

Parameters

$offset

void offsetSet($offset, $value)

No description

Parameters

$offset
$value

Return Value

void

void offsetUnset($offset)

No description

Parameters

$offset

Return Value

void

__construct(Repository $config, StorageDriver $storage, TenantManager $tenantManager, UniqueIdentifierGenerator $idGenerator)

Use new() if you don't want to swap dependencies.

Parameters

Repository $config
StorageDriver $storage
TenantManager $tenantManager
UniqueIdentifierGenerator $idGenerator

static Tenant new(Application $app = null)

Public constructor.

Parameters

Application $app

Return Value

Tenant

static Tenant fromStorage(array $data)

DO NOT CALL THIS METHOD FROM USERLAND. Used by storage drivers to create persisted instances of Tenant.

Parameters

array $data

Return Value

Tenant

static Tenant create(string|string[] $domains, array $data = [])

Create a tenant in a single call.

Parameters

string|string[] $domains
array $data

Return Value

Tenant

Tenant persisted(bool $persisted)

DO NOT CALL THIS METHOD FROM USERLAND UNLESS YOU KNOW WHAT YOU ARE DOING.

Set $persisted.

Parameters

bool $persisted

Return Value

Tenant

bool isPersisted()

Does this model exist in the tenant storage.

Return Value

bool

Tenant addDomains(string|string[] $domains)

Assign domains to the tenant.

Parameters

string|string[] $domains

Return Value

Tenant

Tenant removeDomains(string|string[] $domains)

Unassign domains from the tenant.

Parameters

string|string[] $domains

Return Value

Tenant

Tenant clearDomains()

Unassign all domains from the tenant.

Return Value

Tenant

Tenant withDomains(string|string[] $domains)

Set (overwrite) the tenant's domains.

Parameters

string|string[] $domains

Return Value

Tenant

Tenant withData(array $data)

Set (overwrite) tenant data.

Parameters

array $data

Return Value

Tenant

void generateId()

Generate a random ID.

Return Value

void

Tenant save()

Write the tenant's state to storage.

Return Value

Tenant

Tenant delete()

Delete a tenant from storage.

Return Value

Tenant

Tenant softDelete()

Unassign all domains from the tenant and write to storage.

Return Value

Tenant

string getDatabaseName()

Get the tenant's database's name.

Return Value

string

string getConnectionName()

Get the tenant's database connection's name.

Return Value

string

void get(string|string[] $keys)

Get a value from tenant storage.

Parameters

string|string[] $keys

Return Value

void

Tenant put(string|array<string,mixed> $key, mixed $value = null)

Set a value and write to storage.

Parameters

string|array<string,mixed> $key
mixed $value

Return Value

Tenant

Tenant set($key, $value = null)

No description

Parameters

$key
$value

Return Value

Tenant

Tenant deleteKey(string $key)

Delete a key from the tenant's storage.

Parameters

string $key

Return Value

Tenant

Tenant deleteKeys(array $keys)

Delete keys from the tenant's storage.

Parameters

array $keys

Return Value

Tenant

Tenant with(string $key, mixed $value)

Set a value in the data array without saving into storage.

Parameters

string $key
mixed $value

Return Value

Tenant

mixed run(Closure $closure)

Run a closure inside the tenant's environment.

Parameters

Closure $closure

Return Value

mixed

__get($key)

No description

Parameters

$key

__set($key, $value)

No description

Parameters

$key
$value

__call($method, $parameters)

No description

Parameters

$method
$parameters