diff --git a/README.md b/README.md index 6506de85..6f2e3977 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Open `app/Http/Kernel.php` and make the middleware top priority, so that it gets ```php protected $middlewarePriority = [ \Stancl\Tenancy\Middleware\InitializeTenancy::class, + // ... +]; ``` When a tenant route is visited, but the tenant can't be identified, an exception is thrown. If you want to change this behavior, to a redirect for example, add this to your `app/Providers/AppServiceProvider.php`'s `boot()` method. diff --git a/src/Middleware/InitializeTenancy.php b/src/Middleware/InitializeTenancy.php index cd6383a5..3c37360a 100644 --- a/src/Middleware/InitializeTenancy.php +++ b/src/Middleware/InitializeTenancy.php @@ -25,13 +25,7 @@ class InitializeTenancy try { tenancy()->init(); } catch (\Exception $e) { - // Pass the exception to the onFail function if it takes any parameters. - $callback = $this->onFail; - if ((new \ReflectionFunction($callback))->getNumberOfParameters() > 0) { - $callback($e); - } else { - $callback(); - } + ($this->onFail)($e); } return $next($request);