From 5f2470fad986fbe6fb0263d3c872aa875ec46605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 13 Jun 2020 14:40:30 +0200 Subject: [PATCH] onfail --- source/docs/v3/features/universal-routes.blade.md | 2 ++ source/docs/v3/tenant-identification.blade.md | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/source/docs/v3/features/universal-routes.blade.md b/source/docs/v3/features/universal-routes.blade.md index 4e334bf..341c44b 100644 --- a/source/docs/v3/features/universal-routes.blade.md +++ b/source/docs/v3/features/universal-routes.blade.md @@ -6,6 +6,8 @@ section: content # Universal Routes +> Note: If you need custom [onFail]({{ $page->link('tenant-identification') }}) logic, you cannot use this feature as it will override any of your changes to that logic. Instead, look into the source code of this feature and make your onFail logic implement universal routes too. + Sometimes, you may want to use the exact same **route action** both in the central application and the tenant application. Note the emphasis on route **action** — you may use the same **path** with different actions in central & tenant routes, whereas this section covers using the same **route and action**. Generally, try to avoid these use cases as much as possible and prefer duplicating the code. Using the same controller and model for users in central & tenant apps will break down once you need slightly different behavior — e.g. different views returned by controllers, different behavior on models, etc. diff --git a/source/docs/v3/tenant-identification.blade.md b/source/docs/v3/tenant-identification.blade.md index fb9bff1..68dca6a 100644 --- a/source/docs/v3/tenant-identification.blade.md +++ b/source/docs/v3/tenant-identification.blade.md @@ -96,3 +96,13 @@ InitializeTenancyByRequestData::$queryParameter = null; ## Manually identifying tenants See the [manual initialization page]({{ $page->link('manual-initialization') }}) to see how to identify tenants manually. + +## Customizing onFail logic + +Each identification middleware has a static `$onFail` property that can be used to customize the behavior that should happen when a tenant couldn't be identified. + +```php +\Stancl\Tenancy\Middleware\InitializeTenancyByDomain::$onFail = function ($exception, $request, $next) { + return redirect('https://my-central-domain.com/'); +}; +```