mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 03:34:03 +00:00
wip
This commit is contained in:
parent
8c74cb4d76
commit
060a4bc525
3 changed files with 26 additions and 13 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue