mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 20:54:03 +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);
|
||||
}
|
||||
|
||||
/** Create a pending tenant. */
|
||||
public static function createPending($attributes = []): Tenant
|
||||
{
|
||||
$tenant = static::create($attributes);
|
||||
|
|
@ -66,12 +67,20 @@ trait HasPending
|
|||
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 (! $firstOrCreate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static::createPending();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue