diff --git a/assets/config.php b/assets/config.php index e5c1a24b..81a74258 100644 --- a/assets/config.php +++ b/assets/config.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Stancl\Tenancy\CacheManager; use Stancl\Tenancy\Middleware; use Stancl\Tenancy\Resolvers; @@ -189,6 +190,7 @@ return [ * You can clear cache selectively by specifying the tag. */ 'cache' => [ + 'manager' => CacheManager::class, 'tag_base' => 'tenant', // This tag_base, followed by the tenant_id, will form a tag that will be applied on each cache call. 'prefix_base' => 'tenant_', // This prefix_base, followed by the tenant_id, will form a cache prefix that will be used for every cache key. ], diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index c3a68755..54950771 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -96,10 +96,6 @@ class TenancyServiceProvider extends ServiceProvider return new Commands\MigrateFreshOverride; }); - $this->app->singleton('cache', function ($app) { - return new TenantCacheManager($app); - }); - $this->publishes([ __DIR__ . '/../assets/config.php' => config_path('tenancy.php'), ], 'config'); @@ -138,5 +134,9 @@ class TenancyServiceProvider extends ServiceProvider return $instance; }); + + $this->app->singleton('cache', function ($app) { + return new $this->app['config']['tenancy.cache.manager']($app); + }); } }