1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-03-22 18:44:03 +00:00

Merge branch 'archtechx:3.x' into 3.x

This commit is contained in:
Leandro Gehlen 2025-07-10 07:22:42 -03:00 committed by GitHub
commit 32e3b375ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 114 additions and 19 deletions

View file

@ -18,13 +18,16 @@ trait InvalidatesResolverCache
public static function bootInvalidatesResolverCache()
{
static::saved(function (Tenant $tenant) {
$invalidateCache = static function (Tenant $tenant) {
foreach (static::$resolvers as $resolver) {
/** @var CachedTenantResolver $resolver */
$resolver = app($resolver);
$resolver->invalidateCache($tenant);
}
});
};
static::saved($invalidateCache);
static::deleting($invalidateCache);
}
}

View file

@ -21,13 +21,16 @@ trait InvalidatesTenantsResolverCache
public static function bootInvalidatesTenantsResolverCache()
{
static::saved(function (Model $model) {
$invalidateCache = static function (Model $model) {
foreach (static::$resolvers as $resolver) {
/** @var CachedTenantResolver $resolver */
$resolver = app($resolver);
$resolver->invalidateCache($model->tenant);
}
});
};
static::saved($invalidateCache);
static::deleting($invalidateCache);
}
}

View file

@ -10,6 +10,6 @@ class ModelNotSyncMasterException extends Exception
{
public function __construct(string $class)
{
parent::__construct("Model of $class class is not an SyncMaster model. Make sure you're using the central model to make changes to synced resources when you're in the central context");
parent::__construct("Model of $class class is not a SyncMaster model. Make sure you're using the central model to make changes to synced resources when you're in the central context.");
}
}

View file

@ -18,7 +18,7 @@ class UserImpersonation implements Feature
public function bootstrap(Tenancy $tenancy): void
{
$tenancy->macro('impersonate', function (Tenant $tenant, string $userId, string $redirectUrl, string $authGuard = null): ImpersonationToken {
$tenancy->macro('impersonate', function (Tenant $tenant, string $userId, string $redirectUrl, ?string $authGuard = null): ImpersonationToken {
return ImpersonationToken::create([
'tenant_id' => $tenant->getTenantKey(),
'user_id' => $userId,
@ -32,10 +32,10 @@ class UserImpersonation implements Feature
* Impersonate a user and get an HTTP redirect response.
*
* @param string|ImpersonationToken $token
* @param int $ttl
* @param int|null $ttl
* @return RedirectResponse
*/
public static function makeResponse($token, int $ttl = null): RedirectResponse
public static function makeResponse($token, ?int $ttl = null): RedirectResponse
{
$token = $token instanceof ImpersonationToken ? $token : ImpersonationToken::findOrFail($token);

View file

@ -40,10 +40,8 @@ class InitializeTenancyByPath extends IdentificationMiddleware
return $this->initializeTenancy(
$request, $next, $route
);
} else {
throw new RouteIsMissingTenantParameterException;
}
return $next($request);
throw new RouteIsMissingTenantParameterException;
}
}