class Tenancy (View source)

Traits

Macroable

Properties

Tenant|null $tenant

The current tenant.

Closure|null $getBootstrappersUsing
bool $initialized

Is tenancy fully initialized?

Methods

void
initialize(Tenant|int|string $tenant)

Initialize tenancy for the passed tenant.

void
end()

No description

array
getBootstrappers()

No description

static Builder
query()

No description

static Tenant&Model
model()

No description

static string
tenantKeyColumn()

Name of the column used to relate models to tenants.

static Tenant|null
find(int|string $id)

Try to find a tenant using an ID.

mixed
central(Closure $callback)

Run a callback in the central context.

void
runForMultiple(Tenant[]|(string|int)[]|Traversable|string|int|null $tenants, Closure $callback)

Run a callback for multiple tenants.

static array
cachedResolvers()

Cached tenant resolvers used by the package.

static array
middleware()

Tenant identification middleware used by the package.

static string
defaultMiddleware()

Default tenant identification middleware used by the package.

Details

void initialize(Tenant|int|string $tenant)

Initialize tenancy for the passed tenant.

Parameters

Tenant|int|string $tenant

Return Value

void

void end()

No description

Return Value

void

array getBootstrappers()

No description

Return Value

array

static Builder query()

No description

Return Value

Builder

static Tenant&Model model()

No description

Return Value

Tenant&Model

static string tenantKeyColumn()

Name of the column used to relate models to tenants.

Return Value

string

static Tenant|null find(int|string $id)

Try to find a tenant using an ID.

Parameters

int|string $id

Return Value

Tenant|null

mixed central(Closure $callback)

Run a callback in the central context.

Atomic, safely reverts to previous context.

Parameters

Closure $callback

Return Value

mixed

void runForMultiple(Tenant[]|(string|int)[]|Traversable|string|int|null $tenants, Closure $callback)

Run a callback for multiple tenants.

More performant than running $tenant->run() one by one.

Parameters

Tenant[]|(string|int)[]|Traversable|string|int|null $tenants
Closure $callback

Return Value

void

static array cachedResolvers()

Cached tenant resolvers used by the package.

Return Value

array

static array middleware()

Tenant identification middleware used by the package.

Return Value

array

static string defaultMiddleware()

Default tenant identification middleware used by the package.

Return Value

string