1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 23:54:04 +00:00

Add check to invalidateCache()

This commit is contained in:
Samuel Štancl 2020-06-02 20:26:17 +02:00
parent 5d94727ddd
commit ba7257670f
4 changed files with 89 additions and 45 deletions

View file

@ -6,12 +6,20 @@ namespace Stancl\Tenancy\Resolvers;
use Stancl\Tenancy\Contracts\Domain;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Contracts\TenantResolver;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
class DomainTenantResolver implements TenantResolver
class DomainTenantResolver extends Contracts\CachedTenantResolver
{
public function resolve(...$args): Tenant
/** @var bool */
public static $shouldCache = false;
/** @var int */
public static $cacheTTL = 3600; // seconds
/** @var string|null */
public static $cacheStore = null; // default
public function resolveWithoutCache(...$args): Tenant
{
/** @var Domain $domain */
$domain = config('tenancy.domain_model')::where('domain', $args[0])->first();
@ -22,4 +30,13 @@ class DomainTenantResolver implements TenantResolver
throw new TenantCouldNotBeIdentifiedOnDomainException($domain);
}
public function getArgsForTenant(Tenant $tenant): array
{
$tenant->unsetRelation('domains');
return $tenant->domains->map(function (Domain $domain) {
return [$domain->domain];
})->toArray();
}
}