mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:24:04 +00:00
Move the logic to the middleware
This commit is contained in:
parent
545c2330d4
commit
426d967e38
2 changed files with 14 additions and 14 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue