archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.57k stars 424 forks source link

Registration Workflow #401

Closed ruelluna closed 4 years ago

ruelluna commented 4 years ago

I freshly installed Laravel and giving this a shot.

My current registration workflow that is working are these steps

  1. Create user using App/Models/User (central) with username, email, firstname and lastname as fields.
  2. Creating Tenant.
  3. Run migrations. Has separate users table with model App/Models/Tenant/User.
  4. Redirect to created sub-domain.

I have few questions on my workflow.

  1. Inserting as step 3.5, I want to insert the user into the tenant users table with an admin role (roles are managed in another package) and automatically login the user.
  2. When I'm in the tenant routes, how do I get the user who created the account from my Central users table?
  3. Where do I put the seeders for the tenants and how do I call them?
  4. How do I run new tenant migrations in the middle of development to all tenants (without the need to create a new tenant)

This is my first time setting up a SaaS app. Basically, I'm building a boilerplate to use for future projects.

stancl commented 4 years ago

I'm building this for v3 right now. Will be public next week probably. But, you can get some inspiration here: https://github.com/stancl/tenancy/issues/194

ruelluna commented 4 years ago

Thanks!

So by doing this, https://github.com/stancl/tenancy/issues/194#issuecomment-552500495 you mean to say we could setup the main application to not have users table? If yes, I can go with it.

Also, I couldn't see how can I pull up all tenant data (like a Super Administrator dashboard), where I can see the activity for each tenant. Do you do this my tapping to each tenant's database connection and querying all of that ?

So excited to see your workflow. Will there be any available video tutorials? Thanks much!

stancl commented 4 years ago

you mean to say we could setup the main application to not have users table

Yes, the register tenant page only creates a tenant, and the login tenant page redirects to the login screen on that tenant's domain (we find the tenant by e.g. email).

pull up all tenant data

You either have to loop through all tenants, or you have to use single DB tenancy. That's coming in v3 too.

Will there be any available video tutorials

Possibly at a later point. Now I'm focusing getting the boilerplate & v3 done.