mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:54:03 +00:00
Improve query formatting
This commit is contained in:
parent
3a6e673418
commit
9414b17f06
3 changed files with 3 additions and 6 deletions
|
|
@ -41,8 +41,7 @@ class ClearPendingTenants extends Command
|
||||||
$expirationDate->subHours($olderThanHours);
|
$expirationDate->subHours($olderThanHours);
|
||||||
}
|
}
|
||||||
|
|
||||||
$deletedTenantCount = tenancy()
|
$deletedTenantCount = tenancy()->query()
|
||||||
->query()
|
|
||||||
->onlyPending()
|
->onlyPending()
|
||||||
->when($originalExpirationDate->notEqualTo($expirationDate), function (Builder $query) use ($expirationDate) {
|
->when($originalExpirationDate->notEqualTo($expirationDate), function (Builder $query) use ($expirationDate) {
|
||||||
$query->where($query->getModel()->getColumnForQuery('pending_since'), '<', $expirationDate->timestamp);
|
$query->where($query->getModel()->getColumnForQuery('pending_since'), '<', $expirationDate->timestamp);
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ class CreatePendingTenants extends Command
|
||||||
/** Calculate the number of currently available pending tenants. */
|
/** Calculate the number of currently available pending tenants. */
|
||||||
protected function getPendingTenantCount(): int
|
protected function getPendingTenantCount(): int
|
||||||
{
|
{
|
||||||
return tenancy()
|
return tenancy()->query()
|
||||||
->query()
|
|
||||||
->onlyPending()
|
->onlyPending()
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ trait HasTenantOptions
|
||||||
|
|
||||||
protected function getTenants(): LazyCollection
|
protected function getTenants(): LazyCollection
|
||||||
{
|
{
|
||||||
return tenancy()
|
return tenancy()->query()
|
||||||
->query()
|
|
||||||
->when($this->option('tenants'), function ($query) {
|
->when($this->option('tenants'), function ($query) {
|
||||||
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
$query->whereIn(tenancy()->model()->getTenantKeyName(), $this->option('tenants'));
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue