hipsterjazzbo / Landlord

A simple, single database multi-tenancy solution for Laravel 5.2+
MIT License
614 stars 138 forks source link

Add support for scoping to multiple tenants. #17

Closed 0xn3bs closed 7 years ago

0xn3bs commented 8 years ago

This is useful for tenant hierarchy scenarios as well as administration.

hipsterjazzbo commented 8 years ago

Can you give an example of where you'd use this?

0xn3bs commented 8 years ago

@HipsterJazzbo sure, this is useful in hierarchical tenancy scenarios. I.e. something like:

Tenant A is parent to Tenant B and Tenant C, therefore a user on Tenant A could see data on Tenant A, B, and C. Whereas a user on Tenant B may see data on Tenant A and Tenant B but not Tenant C.

In a real-world situation Tenant A could be "Corporate" and Tenant B and C could be "Franchisees"

hipsterjazzbo commented 7 years ago

Are all those tenants from the same table?

0xn3bs commented 7 years ago

@HipsterJazzbo yes they are.

hipsterjazzbo commented 7 years ago

Hmm I see what you're doing there. However, this library is specifically targeted at doing everything it can to only have ONE of a given tenant registered at any one time, for purposes of data siloing. I think this is outside the scope of this library.

You should be able to whip up your own global scope to handle that situation quite easily though.