To use kernel identification, add InitializeTenancyByPath or InitializeTenancyByRequestData to $middleware in your App/Http/Kernel.php. To use route-level identification, apply the middleware directly to the route – with route-level path identification, you also need to re-register the routes.
Livewire
v2 – In the livewire.php config file (if you don't have it, publish it using php artisan livewire:publish --config), change the value of 'middleware' to ['universal', 'web'].
v3 – update the Livewire update route so that it's universal
Use UrlBindingBootstrapper in your tenancy.php config. The bootstrapper swaps the current 'url' (UrlGenerator) instance for our TenancyUrlGenerator.
a) Path Identification
Set TenancyUrlGenerator's $prefixRouteNames property to true.
// E.g. in TenancyServiceProvider's boot()
TenancyUrlGenerator::$prefixRouteNames = true;
Make sure you re-register routes (including the LW routes) in your TenancyServiceProvider's boot() method.
Livewire v2
Assign ['universal', 'web'] (or ['universal', 'web', IdentificationMW::class] if you want route-level identification) to the'middleware_group'LW config key (in livewire.php).
Call the following code in your TenancyServiceProvider's boot() method:
Note: Don't forget to also re-register the routes when using route-level path identification with package routes
To use kernel identification, add InitializeTenancyByPath or InitializeTenancyByRequestData to $middleware in your App/Http/Kernel.php. To use route-level identification, apply the middleware directly to the route – with route-level path identification, you also need to re-register the routes.
Livewire
php artisan livewire:publish --config
), change the value of 'middleware' to['universal', 'web']
.Use UrlBindingBootstrapper in your tenancy.php config. The bootstrapper swaps the current 'url' (UrlGenerator) instance for our TenancyUrlGenerator.
a) Path Identification
Set TenancyUrlGenerator's
$prefixRouteNames
property totrue
.Make sure you re-register routes (including the LW routes) in your TenancyServiceProvider's
boot()
method.Livewire v2 Assign
['universal', 'web']
(or['universal', 'web', IdentificationMW::class]
if you want route-level identification) to the'middleware_group'
LW config key (in livewire.php).Call the following code in your TenancyServiceProvider's
boot()
method:Also, update the app URL in your layout's script like this:
Livewire v3 Call the following code in your TenancyServiceProvider's
boot()
method:b) Request data identification
Make sure the TenancyUrlGenerator's $prefixRouteNames property is
false
.Livewire v2 Add the tenant header to the global
window.Livewire.connection.headers
JS property in your layout view, e.g.:Livewire v3 Call the following code in your TenancyServiceProvider's boot() method:
Add the tenant header in your layout view like this:
To make file uploads work, follow the real-time facades docs page to create framework directories.