mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:54:05 +00:00
add pullPendingTenantFromPool
This commit is contained in:
parent
e93a5181c3
commit
090fc475eb
1 changed files with 10 additions and 1 deletions
|
|
@ -49,6 +49,7 @@ trait HasPending
|
||||||
return ! is_null($this->pending_since);
|
return ! is_null($this->pending_since);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Create a pending tenant. */
|
||||||
public static function createPending($attributes = []): Tenant
|
public static function createPending($attributes = []): Tenant
|
||||||
{
|
{
|
||||||
$tenant = static::create($attributes);
|
$tenant = static::create($attributes);
|
||||||
|
|
@ -66,12 +67,20 @@ trait HasPending
|
||||||
return $tenant;
|
return $tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function pullPendingTenant(bool $firstOrCreate = false): ?Tenant
|
/** Pull a pending tenant. */
|
||||||
|
public static function pullPendingTenant(): Tenant
|
||||||
|
{
|
||||||
|
return static::pullPendingTenantFromPool(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Try to pull a tenant from the pool of pending tenants. */
|
||||||
|
public static function pullPendingTenantFromPool(bool $firstOrCreate = false): ?Tenant
|
||||||
{
|
{
|
||||||
if (! static::onlyPending()->exists()) {
|
if (! static::onlyPending()->exists()) {
|
||||||
if (! $firstOrCreate) {
|
if (! $firstOrCreate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static::createPending();
|
static::createPending();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue