Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple Tenant Domains #4

Closed
wants to merge 3 commits into from
Closed

Conversation

Rigby90
Copy link
Contributor

@Rigby90 Rigby90 commented May 12, 2020

First of all, appreciate the work on this and how quickly you've turned it from an idea into a solution!

I am building a solution for a client which does not require a tenant to have a domain, instead a user is able to select the current tenant by dropdown. This value is then stored in the session data and we set the correct tenant using a custom tenant finder. My only concern here is that currently a tenant 'requires' a domain name as the current table structure of the 'tenants' table forces a non-null unique value for the domains field. This is not a deal-breaker as we could create a random string and fill in the field for tenants which don't have a domain, and then find a way to filter it out from the backend interface when it's not a real domain.

In addition to this, there's also the requirement of a tenant having multiple domains. Whether this consists of the www and non-www variants of their domain, or additional domains that the client may hold and would like assigning to the same tenant.

With that being said, this PR should handle both situations. The PR is not complete in terms of tests or actual real-world testing, however, it provides the basis for a proof of concept and all tests pass. Only 1 existing test had to be modified slightly due to the domain being passed through to the Tenant to be created.

Would welcome any thoughts on this and what additional tests & logic may be required to get such a PR merged if at all possible.

Appreciate your time if you've made it this far 馃槃

(PS, there's two additional commits to get the test suite working on Windows and to extract some additional MySQL details into the PHPUnit Environment Variables.)

This also adds the ability for a tenant to have 0 domains as well, with the tenant being set by custom logic such as session data etc.
@freekmurze
Copy link
Member

Thank you for your kinds words and your work on this PR.

I'm not going to merge it in, as I feel it goes against the philosophy of keeping the package as light as possible.

If you want to support multiple domains, use a custom Tenant model. In your custom tenant models you could add a relation to a domains table in your project. You can use a custom TenantFinder to look for tenants having a relation to the domain you want.

PS, there's two additional commits to get the test suite working on Windows and to extract some additional MySQL details into the PHPUnit Environment Variables.

Could you send these changes in a separate PR? Thanks!

@freekmurze freekmurze closed this May 12, 2020
@Rigby90
Copy link
Contributor Author

Rigby90 commented May 12, 2020

Completely understand the reasoning, will proceed with a custom tenant model.

Will open another PR for the other two commits. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants