mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:14:04 +00:00
Removed select() for better flexibility, added new method setCurrentDomain(), refactored the usage of tenantIdentified().
This commit is contained in:
parent
e4a3211b34
commit
643a64b5c8
1 changed files with 7 additions and 2 deletions
|
|
@ -33,13 +33,13 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
||||||
/** @var Tenant|null $tenant */
|
/** @var Tenant|null $tenant */
|
||||||
$tenant = config('tenancy.tenant_model')::query()
|
$tenant = config('tenancy.tenant_model')::query()
|
||||||
->whereHas('domains', function ($query) use ($domain) {
|
->whereHas('domains', function ($query) use ($domain) {
|
||||||
$query->select(['tenant_id', 'domain'])->where('domain', $domain);
|
$query->where('domain', $domain);
|
||||||
})
|
})
|
||||||
->with('domains')
|
->with('domains')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($tenant) {
|
if ($tenant) {
|
||||||
$this->tenantIdentified($tenant, ...$args);
|
$this->setCurrentDomain($tenant, ...$args);
|
||||||
|
|
||||||
return $tenant;
|
return $tenant;
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +48,11 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tenantIdentified(Tenant $tenant, ...$args): void
|
public function tenantIdentified(Tenant $tenant, ...$args): void
|
||||||
|
{
|
||||||
|
$this->setCurrentDomain($tenant, ...$args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setCurrentDomain(Tenant $tenant, ...$args): void
|
||||||
{
|
{
|
||||||
static::$currentDomain = $tenant->domains->where('domain', $args[0])->first();
|
static::$currentDomain = $tenant->domains->where('domain', $args[0])->first();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue