mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:54:05 +00:00
Fixed tenant()->domains showing incorrect data. Renamed tenantIdentifiedFromCache() method and removed duplicate code, when setting current domain.
This commit is contained in:
parent
1d3bb6dc27
commit
e4a3211b34
2 changed files with 6 additions and 10 deletions
|
|
@ -38,7 +38,7 @@ abstract class CachedTenantResolver implements TenantResolver
|
|||
|
||||
if ($this->cache->has($key)) {
|
||||
$tenant = $this->cache->get($key);
|
||||
$this->tenantIdentifiedFromCache($tenant, ...$args);
|
||||
$this->tenantIdentified($tenant, ...$args);
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ abstract class CachedTenantResolver implements TenantResolver
|
|||
|
||||
abstract public function resolveWithoutCache(...$args): Tenant;
|
||||
|
||||
public function tenantIdentifiedFromCache(Tenant $tenant, ...$args): void
|
||||
public function tenantIdentified(Tenant $tenant, ...$args): void
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,11 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
|||
->whereHas('domains', function ($query) use ($domain) {
|
||||
$query->select(['tenant_id', 'domain'])->where('domain', $domain);
|
||||
})
|
||||
->with([
|
||||
'domains' => function ($query) use ($domain) {
|
||||
$query->where('domain', $domain);
|
||||
},
|
||||
])
|
||||
->with('domains')
|
||||
->first();
|
||||
|
||||
if ($tenant) {
|
||||
static::$currentDomain = $tenant->domains->first();
|
||||
$this->tenantIdentified($tenant, ...$args);
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
|
@ -51,9 +47,9 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
|||
throw new TenantCouldNotBeIdentifiedOnDomainException($args[0]);
|
||||
}
|
||||
|
||||
public function tenantIdentifiedFromCache(Tenant $tenant, ...$args): void
|
||||
public function tenantIdentified(Tenant $tenant, ...$args): void
|
||||
{
|
||||
static::$currentDomain = $tenant->domains->first();
|
||||
static::$currentDomain = $tenant->domains->where('domain', $args[0])->first();
|
||||
}
|
||||
|
||||
public function getArgsForTenant(Tenant $tenant): array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue