Tenant identifier appended to the end of URL
reefki opened this issue · 3 comments
When calling Multitenancy::url()
the tenant identifier being appended to the end of URL.
Multitenancy::url();
// http://foo.domain.com/foo.domain.com`
Multitenancy::url('/path');
// http://foo.domain.com/path/foo.domain.com`
@reefki I think that's an oversight on my end. url()
will use the current domain.
There's probably no need at all for this method, I'm planning to take a look this evening as well add a couple of things.
@ollieread Yeah I was thinking the same, but it may be useful if the url
method moved to the Tenant
trait. For example, when viewing the list of tenants in we could also show a link to the URL of each tenant.
I also have a couple of suggestions:
- Instead of using
getTenantKey
inTenantOwned
trait, I think it would be nice and simpler if we can set this value globally in the config file, so no need to define this method on every model. - Add tenant relationship on
TenantOwned
trait, currently, we need to define it manually on each model. - Automatically associate current tenant when creating/saving a model within
boot
method onTenantOwned
trait. - Add force redirection from primary identifier to secondary identifier when secondary identifier not empty, it would be great if we can set it on/off at both the global level and individual tenant level.
I really want to pull some PR but don't have enough time at the moment.
The reason that you define the FK is that some people will use different key names across different models. I get that it's not ideal, but they do it anyway. Also, because of the way Laravel works, Eloquent will generate a brand new query for a whereHas()
, which as you can imagine, is not ideal.
I've been meaning to add a couple of new traits, TenantOwnedThrough
and TenantOwnedRelation
as an alternative.
The force redirect is interesting. I wouldn't actually make the package force the redirect but I can take a look at making it easier for you to identify which identifier has been used.