पेज · Laravilt
Middleware & Routing
How tenants are identified per request and how tenant routes are named.
Middleware
All middleware lives in Laravilt\Panel\Middleware.
InitializeTenancyBySubdomain
Used in multi-database mode:
- Extracts the subdomain from the host
- Rejects reserved subdomains
- Finds the tenant by domain or slug
- Switches to the tenant database
- Sets the tenant context
IdentifyTenant
Used in single-database mode:
- Reads the tenant from the route parameter
- Checks the user can access it
- Sets the tenant context (no database switch)
PreventAccessFromCentralDomains
Blocks tenant-only routes when they're requested on a central domain.
Route Naming
| Context | Name prefix | Example |
|---|---|---|
| Panel routes | {panel}. | admin.dashboard |
| Subdomain (multi-database) routes | {panel}.subdomain. | admin.subdomain.dashboard |
Multiple Panels
Each panel configures tenancy on its own:
php
Checking State
php