1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 11:14:03 +00:00
tenancy/source/docs/tenant-routes.md
Samuel Štancl a92690cea8 wip
2019-08-16 22:09:01 +02:00

1.3 KiB

title description extends section
Tenant Routes Tenant routes with stancl/tenancy — A Laravel multi-database tenancy package that respects your code.. _layouts.documentation content

Tenant Routes

Routes within routes/tenant.php will have the web middleware group and the IntializeTenancy middleware automatically applied on them. This middleware attempts to identify the tenant based on the current hostname. Once the tenant is identified, the database connection, cache, filesystem root paths and, optionally, Redis connection, will be switched.

Just like routes/web.php, these routes use the App\Http\Controllers namespace.

If a tenant cannot be identified, anexception will be thrown. If you want to change this behavior (to a redirect, for example) read the Middleware Configuration page.

Exempt routes

Routes outside the routes/tenant.php file will not have the tenancy middleware automatically applied on them. You can apply this middleware manually, though.

If you want some of your, say, API routes to be multi-tenant, simply wrap them in a Route group with this middleware:

use Stancl\Tenancy\Middleware\InitializeTenancy;

Route::middleware(InitializeTenancy::class)->group(function () {
    // Route::get('/', 'HelloWorld');
});