mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Use Telescope tags on universal routes too - fix #346
This commit is contained in:
parent
5044339da6
commit
56903d20bf
2 changed files with 6 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Features;
|
||||||
use Laravel\Telescope\IncomingEntry;
|
use Laravel\Telescope\IncomingEntry;
|
||||||
use Laravel\Telescope\Telescope;
|
use Laravel\Telescope\Telescope;
|
||||||
use Stancl\Tenancy\Contracts\Feature;
|
use Stancl\Tenancy\Contracts\Feature;
|
||||||
|
use Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains;
|
||||||
use Stancl\Tenancy\TenantManager;
|
use Stancl\Tenancy\TenantManager;
|
||||||
|
|
||||||
class TelescopeTags implements Feature
|
class TelescopeTags implements Feature
|
||||||
|
|
@ -30,7 +31,10 @@ class TelescopeTags implements Feature
|
||||||
Telescope::tag(function (IncomingEntry $entry) {
|
Telescope::tag(function (IncomingEntry $entry) {
|
||||||
$tags = $this->getTags($entry);
|
$tags = $this->getTags($entry);
|
||||||
|
|
||||||
if (in_array('tenancy', optional(request()->route())->middleware() ?? [])) {
|
$tenantRoute = PreventAccessFromTenantDomains::routeHasMiddleware(request()->route(), 'tenancy')
|
||||||
|
|| PreventAccessFromTenantDomains::routeHasMiddleware(request()->route(), 'universal');
|
||||||
|
|
||||||
|
if ($tenantRoute) {
|
||||||
$tags = array_merge($tags, [
|
$tags = array_merge($tags, [
|
||||||
'tenant:' . tenant('id'),
|
'tenant:' . tenant('id'),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class PreventAccessFromTenantDomains
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeHasMiddleware(Route $route, $middleware): bool
|
public static function routeHasMiddleware(Route $route, $middleware): bool
|
||||||
{
|
{
|
||||||
if (in_array($middleware, $route->middleware(), true)) {
|
if (in_array($middleware, $route->middleware(), true)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue