1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 18:04:03 +00:00

[1.8.0] Add Telescope tags with tenant ids (#77)

This commit is contained in:
Samuel Štancl 2019-08-19 21:11:55 +02:00 committed by GitHub
parent 8d8c177dac
commit 824ecfce48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 0 deletions

View file

@ -2,6 +2,7 @@
namespace Stancl\Tenancy;
use Laravel\Telescope\Telescope;
use Stancl\Tenancy\Commands\Run;
use Stancl\Tenancy\Commands\Seed;
use Illuminate\Cache\CacheManager;
@ -49,10 +50,30 @@ class TenancyServiceProvider extends ServiceProvider
$this->app->register(TenantRouteServiceProvider::class);
if (\class_exists(Telescope::class)) {
$this->setTelescopeTags();
}
$this->registerTenantRedirectMacro();
$this->makeQueuesTenantAware();
}
public function setTelescopeTags()
{
Telescope::tag(function (\Laravel\Telescope\IncomingEntry $entry) {
$tags = $this->app->make(TenantManager::class)->integration('telescope', $entry);
if (\in_array('tenancy', request()->route()->middleware())) {
$tags = \array_merge($tags, [
'tenant:' . tenant('uuid'),
'domain:' . tenant('domain'),
]);
}
return $tags;
});
}
public function registerTenantRedirectMacro()
{
RedirectResponse::macro('tenant', function (string $domain) {