1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 05:44:04 +00:00

Move the logic to the middleware

This commit is contained in:
Samuel Štancl 2019-08-08 22:29:13 +02:00
parent 545c2330d4
commit 426d967e38
2 changed files with 14 additions and 14 deletions

View file

@ -3,6 +3,7 @@
namespace Stancl\Tenancy\Middleware; namespace Stancl\Tenancy\Middleware;
use Closure; use Closure;
use Laravel\Telescope\Telescope;
class InitializeTenancy class InitializeTenancy
{ {
@ -28,6 +29,19 @@ class InitializeTenancy
($this->onFail)($e); ($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); return $next($request);
} }
} }

View file

@ -2,7 +2,6 @@
namespace Stancl\Tenancy; namespace Stancl\Tenancy;
use Laravel\Telescope\Telescope;
use Stancl\Tenancy\Commands\Seed; use Stancl\Tenancy\Commands\Seed;
use Illuminate\Cache\CacheManager; use Illuminate\Cache\CacheManager;
use Stancl\Tenancy\Commands\Migrate; use Stancl\Tenancy\Commands\Migrate;
@ -42,19 +41,6 @@ class TenancyServiceProvider extends ServiceProvider
]); ]);
$this->app->register(TenantRouteServiceProvider::class); $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);
});
}
} }
/** /**