mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:14:04 +00:00
Remove withPending from runForMultiple
This commit is contained in:
parent
c44a4c56d5
commit
fd809bc81a
2 changed files with 3 additions and 33 deletions
|
|
@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Support\Traits\Macroable;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Database\Concerns\PendingScope;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedById;
|
||||
|
||||
class Tenancy
|
||||
|
|
@ -131,15 +130,10 @@ class Tenancy
|
|||
* @param Tenant[]|\Traversable|string[]|null $tenants
|
||||
* @return void
|
||||
*/
|
||||
public function runForMultiple($tenants, callable $callback, bool $withPending = null)
|
||||
public function runForMultiple($tenants, callable $callback)
|
||||
{
|
||||
$query = $this->model()->newQuery();
|
||||
|
||||
if (is_bool($withPending) && $this->model()::hasGlobalScope(PendingScope::class)) {
|
||||
$query->withPending($withPending);
|
||||
}
|
||||
// Convert null to all tenants
|
||||
$tenants = is_null($tenants) ? $query->cursor() : $tenants;
|
||||
$tenants = is_null($tenants) ? $this->model()->cursor() : $tenants;
|
||||
|
||||
// Convert incrementing int ids to strings
|
||||
$tenants = is_int($tenants) ? (string) $tenants : $tenants;
|
||||
|
|
@ -148,7 +142,7 @@ class Tenancy
|
|||
$tenants = is_string($tenants) ? [$tenants] : $tenants;
|
||||
|
||||
// Use all tenants if $tenants is falsy
|
||||
$tenants = $tenants ?: $query->cursor();
|
||||
$tenants = $tenants ?: $this->model()->cursor();
|
||||
|
||||
$originalTenant = $this->tenant;
|
||||
|
||||
|
|
|
|||
|
|
@ -169,28 +169,4 @@ class PendingTenantsTest extends TestCase
|
|||
Event::assertDispatched(PullingPendingTenant::class);
|
||||
Event::assertDispatched(PendingTenantPulled::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function tenancy_run_for_multiple_can_scope_pending_tenants()
|
||||
{
|
||||
config(['tenancy.pending.include_in_queries' => false]);
|
||||
|
||||
Tenant::createPending();
|
||||
Tenant::create();
|
||||
|
||||
$executedCount = 0;
|
||||
tenancy()->runForMultiple([], function () use (&$executedCount){
|
||||
$executedCount++;
|
||||
}, false);
|
||||
|
||||
self::assertEquals(1, $executedCount);
|
||||
|
||||
$executedCount = 0;
|
||||
|
||||
tenancy()->runForMultiple([], function () use (&$executedCount){
|
||||
$executedCount++;
|
||||
}, true);
|
||||
|
||||
self::assertEquals(2, $executedCount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue