mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:14:02 +00:00
21 lines
No EOL
545 B
PHP
21 lines
No EOL
545 B
PHP
<?php
|
|
|
|
namespace Stancl\Tenancy\Resolvers;
|
|
|
|
use Stancl\Tenancy\Contracts\Tenant;
|
|
use Stancl\Tenancy\Contracts\TenantResolver;
|
|
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
|
|
|
|
class DomainTenantResolver implements TenantResolver
|
|
{
|
|
public function resolve(...$args): Tenant
|
|
{
|
|
$domain = config('tenancy.domain_model')::where('domain', $args[0])->first();
|
|
|
|
if ($domain) {
|
|
return $domain->tenant;
|
|
}
|
|
|
|
throw new TenantCouldNotBeIdentifiedOnDomainException($domain);
|
|
}
|
|
} |