gruz / multi-tenancy-voyager-tries

Laravel-tenancy Voyager integration
9 stars 6 forks source link

Few Questions #2

Closed Mr-Black-Dahlia closed 5 years ago

Mr-Black-Dahlia commented 5 years ago

Thanks for this awesome code! Just have a few questions

  1. When adding a new hostname via the admin panel, does this automatically edit the hosts file? How can I make it so when I add a new hostname via the admin it takes care of the necessary stuff? I am going to be creating new tenants via an api.

  2. Does each tenant have their own users tables etc? Is it possible to specify a username/password on tenant creation?

gruz commented 5 years ago
  1. No. It's impossible via a regular PHP. This would demnad a conjunction of your server configuration and probably bash scripting. But most important - it would not be needed for a real online environment. And for localhost testing you can add a set of several tenant domains manually. You can add any activity on tenant creation. Check "app\Tenant.php" file approximately here https://github.com/gruz/multi-tenancy-voyager-tries/blob/master/app/Tenant.php#L77

  2. Yes, each tenant have separate users. In this general solution you just add a default user. But I have is implemented at my main job project. You need some coding for this.

Here on tenant creation we install Voyager with dummy data. https://github.com/gruz/multi-tenancy-voyager-tries/blob/master/app/Tenant.php#L89

Mr-Black-Dahlia commented 5 years ago
  1. Oh my mistake. I was confusing the local dev for online development. Sorry about that. I forgot the hosts file is for the local dev part only.

  2. Perfect thank you for showing me where to look.


I just got this installed and everything seems to be working right, but when I try to add a new hostname via admin panel I get this:

SQLSTATE[HY000]: General error: 1470 String '4387a90e-c605-4a3b-98c1-2421c3fdff54' is too long for user name (should be no longer than 32) (SQL: CREATE USER IF NOT EXISTS 4387a90e-c605-4a3b-98c1-2421c3fdff54@'localhost' IDENTIFIED BY '$1$rasmusle$OFmAopCPKldhR.wcQMlHs0')

I'm using mysql and did make the changes I saw in the other post. Thanks for the help! This is an amazing asset!

Mr-Black-Dahlia commented 5 years ago

I fixed this issue by applying a 32limit to the UUID. Added to .env:

https://github.com/tenancy/multi-tenant/issues/269#issuecomment-416142999

This also can be fixed by opening up tenancy.php and editing this line:

'uuid-limit-length-to-32' => env('LIMIT_UUID_LENGTH_32', false)

I was able to add a tenant. But going to the subdomain it gives a not found. It's a wildcard setup. Does it need to be set to the public folder?

Yep that was it. It's working 100%. Wow. This is amazing. Thank you so much.