1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 08:44:04 +00:00
This commit is contained in:
Samuel Štancl 2019-08-17 22:18:42 +02:00
parent 8c74cb4d76
commit 060a4bc525
3 changed files with 26 additions and 13 deletions

View file

@ -29,19 +29,6 @@ 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);
}
}

View file

@ -3,6 +3,7 @@
namespace Stancl\Tenancy;
use Stancl\Tenancy\Commands\Run;
use Laravel\Telescope\Telescope;
use Stancl\Tenancy\Commands\Seed;
use Illuminate\Cache\CacheManager;
use Stancl\Tenancy\Commands\Install;
@ -43,6 +44,28 @@ class TenancyServiceProvider extends ServiceProvider
]);
$this->app->register(TenantRouteServiceProvider::class);
if (class_exists(Telescope::class)) {
$this->setTelescopeTags();
}
}
public function setTelescopeTags()
{
$original_callback = Telescope::$tagUsing;
Telescope::tag(function (\Laravel\Telescope\IncomingEntry $entry) use ($original_callback) {
$tags = [];
if (! is_null($original_callback)) {
$tags = $original_callback($entry);
}
if (in_array('tenancy', request()->route()->middleware())) {
$tags = array_merge($tags, ['tenant:' . tenant('uuid')]);
}
return $tags;
});
}
/**

View file

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Artisan;
class TelescopeTest extends TestCase
{
public $autoCreateTenant = false;
public $autoInitTenancy = false;
public function setUp(): void
{
Artisan::call('telescope:install');