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:
parent
8d8c177dac
commit
824ecfce48
3 changed files with 64 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue