mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 00:04:03 +00:00
Added middlewareUniversalName static variable to extends and customize the UniversalRoutes class
This commit is contained in:
parent
04193cc2fd
commit
7653fefefd
1 changed files with 5 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare (strict_types = 1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Features;
|
namespace Stancl\Tenancy\Features;
|
||||||
|
|
||||||
|
|
@ -13,6 +13,8 @@ use Stancl\Tenancy\Tenancy;
|
||||||
|
|
||||||
class UniversalRoutes implements Feature
|
class UniversalRoutes implements Feature
|
||||||
{
|
{
|
||||||
|
public static $middlewareUniversalName = 'universal';
|
||||||
|
|
||||||
public static $identificationMiddlewares = [
|
public static $identificationMiddlewares = [
|
||||||
Middleware\InitializeTenancyByDomain::class,
|
Middleware\InitializeTenancyByDomain::class,
|
||||||
Middleware\InitializeTenancyBySubdomain::class,
|
Middleware\InitializeTenancyBySubdomain::class,
|
||||||
|
|
@ -22,7 +24,7 @@ class UniversalRoutes implements Feature
|
||||||
{
|
{
|
||||||
foreach (static::$identificationMiddlewares as $middleware) {
|
foreach (static::$identificationMiddlewares as $middleware) {
|
||||||
$middleware::$onFail = function ($exception, $request, $next) {
|
$middleware::$onFail = function ($exception, $request, $next) {
|
||||||
if (static::routeHasMiddleware($request->route(), 'universal')) {
|
if (static::routeHasMiddleware($request->route(), static::$middlewareUniversalName)) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +43,7 @@ class UniversalRoutes implements Feature
|
||||||
// groups have the searhced middleware group inside them
|
// groups have the searhced middleware group inside them
|
||||||
$middlewareGroups = Router::getMiddlewareGroups();
|
$middlewareGroups = Router::getMiddlewareGroups();
|
||||||
foreach ($route->gatherMiddleware() as $inner) {
|
foreach ($route->gatherMiddleware() as $inner) {
|
||||||
if (! $inner instanceof Closure && isset($middlewareGroups[$inner]) && in_array($middleware, $middlewareGroups[$inner], true)) {
|
if (!$inner instanceof Closure && isset($middlewareGroups[$inner]) && in_array($middleware, $middlewareGroups[$inner], true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue