mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:14:03 +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)) {
|
if ($this->cache->has($key)) {
|
||||||
$tenant = $this->cache->get($key);
|
$tenant = $this->cache->get($key);
|
||||||
$this->tenantIdentifiedFromCache($tenant, ...$args);
|
$this->tenantIdentified($tenant, ...$args);
|
||||||
|
|
||||||
return $tenant;
|
return $tenant;
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ abstract class CachedTenantResolver implements TenantResolver
|
||||||
|
|
||||||
abstract public function resolveWithoutCache(...$args): Tenant;
|
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) {
|
->whereHas('domains', function ($query) use ($domain) {
|
||||||
$query->select(['tenant_id', 'domain'])->where('domain', $domain);
|
$query->select(['tenant_id', 'domain'])->where('domain', $domain);
|
||||||
})
|
})
|
||||||
->with([
|
->with('domains')
|
||||||
'domains' => function ($query) use ($domain) {
|
|
||||||
$query->where('domain', $domain);
|
|
||||||
},
|
|
||||||
])
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($tenant) {
|
if ($tenant) {
|
||||||
static::$currentDomain = $tenant->domains->first();
|
$this->tenantIdentified($tenant, ...$args);
|
||||||
|
|
||||||
return $tenant;
|
return $tenant;
|
||||||
}
|
}
|
||||||
|
|
@ -51,9 +47,9 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
||||||
throw new TenantCouldNotBeIdentifiedOnDomainException($args[0]);
|
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
|
public function getArgsForTenant(Tenant $tenant): array
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue