From 2c1cc41b97d1ca4220b8ed0b12b2f484748b3cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 21 May 2020 18:05:02 +0200 Subject: [PATCH] Telescope tags --- assets/config.php | 1 + src/Features/TelescopeTags.php | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/Features/TelescopeTags.php diff --git a/assets/config.php b/assets/config.php index fec50a75..11eee8df 100644 --- a/assets/config.php +++ b/assets/config.php @@ -161,6 +161,7 @@ return [ */ 'features' => [ // Stancl\Tenancy\Features\UserImpersonation::class, + // Stancl\Tenancy\Features\TelescopeTags::class, // Stancl\Tenancy\Features\TenantConfig::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-config/ // Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancy.samuelstancl.me/docs/v2/features/tenant-redirect/ ], diff --git a/src/Features/TelescopeTags.php b/src/Features/TelescopeTags.php new file mode 100644 index 00000000..78dd51ec --- /dev/null +++ b/src/Features/TelescopeTags.php @@ -0,0 +1,48 @@ +getTags($entry); + + if (! request()->route()) { + return $tags; + } + + if (tenancy()->initialized) { + $tags = array_merge($tags, [ + 'tenant:' . tenant('id'), + ]); + } + + return $tags; + }); + } + + public static function getTags(IncomingEntry $entry): array + { + $callback = static::$getTagsUsing ?? function () { + return []; + }; + + return $callback($entry); + } +} \ No newline at end of file