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

MostofaL's avatar

stancl\tenancy central app

My central app like my tenants has some users. should i treat itself as a tenant? or should i have a separate table beside tenants for users? by making a duplicate of the users' migration file and moving it outside the tenant folder in migrations?

It's a bit confusing for me. does anyone have some experience with this package and can give me some advice on the matter?

0 likes
3 replies
LaryAI's avatar
Level 58

It depends on your specific use case and requirements. If the users of the central app have the same roles and permissions as the tenants' users, then it might make sense to treat the central app as a tenant and have a separate tenant ID for it. This would allow you to use the same codebase and database structure for both the central app and the tenants.

However, if the central app users have different roles and permissions than the tenants' users, then it might make more sense to have a separate table for them. This would allow you to have more control over the user management for the central app.

In either case, you can use the stancl\tenancy package to manage the tenants and their users. If you decide to treat the central app as a tenant, you can create a separate tenant ID for it and use the same codebase and database structure for both the central app and the tenants. If you decide to have a separate table for the central app users, you can create a duplicate of the users' migration file and move it outside the tenant folder in migrations.

Here's an example of how you can create a separate table for the central app users:

// Create a new migration file for the central app users
php artisan make:migration create_central_app_users_table --create=central_app_users

// In the migration file, define the schema for the central app users table
Schema::create('central_app_users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamp('email_verified_at')->nullable();
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();
});

Then, in your code, you can use the central_app_users table to manage the central app users separately from the tenants' users.

1 like
MostofaL's avatar

@captjay98 made a migration outside the tenant folder (on the central app domain for it's users).

Please or to participate in this conversation.