From 426d967e384ab3393d50cf5863b376d603f72f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 8 Aug 2019 22:29:13 +0200 Subject: [PATCH] Move the logic to the middleware --- src/Middleware/InitializeTenancy.php | 14 ++++++++++++++ src/TenancyServiceProvider.php | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Middleware/InitializeTenancy.php b/src/Middleware/InitializeTenancy.php index 3c37360a..d611b2df 100644 --- a/src/Middleware/InitializeTenancy.php +++ b/src/Middleware/InitializeTenancy.php @@ -3,6 +3,7 @@ namespace Stancl\Tenancy\Middleware; use Closure; +use Laravel\Telescope\Telescope; class InitializeTenancy { @@ -28,6 +29,19 @@ class InitializeTenancy ($this->onFail)($e); } + if (class_exists(Telescope::class)) { + $original_callback = Telescope::tagUsing; + + Telescope::tag(function (\Laravel\Telescope\IncomingEntry $entry) use ($original_callback) { + $tags = []; + if (tenancy()->initialized) { + $tags = ['tenant:' . tenant('uuid')]; + } + + return array_merge($original_callback($entry), $tags); + }); + } + return $next($request); } } diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 13209798..12005e9f 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -2,7 +2,6 @@ namespace Stancl\Tenancy; -use Laravel\Telescope\Telescope; use Stancl\Tenancy\Commands\Seed; use Illuminate\Cache\CacheManager; use Stancl\Tenancy\Commands\Migrate; @@ -42,19 +41,6 @@ class TenancyServiceProvider extends ServiceProvider ]); $this->app->register(TenantRouteServiceProvider::class); - - if (class_exists(Telescope::class)) { - $original_callback = Telescope::tagUsing; - - Telescope::tag(function (\Laravel\Telescope\IncomingEntry $entry) use ($original_callback) { - $tags = []; - if (tenancy()->initialized) { - $tags = ['tenant:' . tenant('uuid')]; - } - - return array_merge($original_callback($entry), $tags); - }); - } } /**