Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mschotamaster's avatar

Stancl/tenancy tenant still connected to main database

I have implemented the stancl/tenancy package in laravel 9 application. tenant, database, migration everything is working fine. But tenant is not connecting its own database for example if I register a user on tenant its adding in the main database. I'm not sure where should I have to give tenant database path. in tenancy(config) file where should i give tenant db? Any example. Sorry not good in English

0 likes
7 replies
mikromike's avatar

Hello I have same problem, stancl/tenancy 3.7 + Laravel 10.10 + laravel/breeze 1.21.

My setup is, I have central db for managment and each tenant has own db. I able to login to central and create new tenant, but once Tenant has been created, not able to login tenant.

I have noted that App\http\requests\Auth\Loginrequest.php does not know about tenant db. I have tried to enable universal routes, but did not fix the problem.

mikromike's avatar

@Ganesh Adhikari : no, I have discarded that project, I have never found solution for it.

Kibissom's avatar

I had the same problem today and this solution worked for me:

Stancl/tenancy 3.9 | laravel/breeze 2.3 | laravel 12

Web.php:

foreach (config('tenancy.central_domains') as $domain) { Route:: domain($domain)→group(function () { // your actual routes

require __DIR__.'/auth.php'; // include this line

});

tenant.php:

Route:: middleware([ 'web', InitializeTenancyByDomain :: class, PreventAccessFromCentralDomains:: class, ])→group(function () { Route::get('/', function () {return 'This is your multi-tenant application. The id of the current tenant});

require __DIR__.'/auth.php'; // include this line

});

Please or to participate in this conversation.