Closed giorgiopogliani closed 4 months ago
This isn't done by the package automatically because there's no way for the package to know what the correct domain is:
You should manually update app.url
or use app('url')->forceRoot()
with the right hostname.
We've added a bootstrapper for this in v4 but it still requires configuration due to the reasons above.
Could we add a primary domain config somewhere, maybe as extra column in the domains table?
Yes, you can do that. It's up to you how you approach this, the right solution here will be application-specific.
Ok, might be a common use case, anyway I'll handle it. Thanks for the super fast reply!
In v4 we've added:
domains->first()
iircIn the SaaS boilerplate we use this primary domain concept. iirc it's a hasOne()
relation from the tenant.
The package won't ship with primary domains out of the box since they only make sense when you really do need multiple domains and have some UI for letting the tenant manage their domains. But the changes we've made should add a good default implementation for this use case.
Bug description
I am sending an email in a job and I am passing to the template an url using the
route
helper. The email is sent with the central domain instead of the tenant context domain.Logging
tenancy()->tenant
shows that the tenant is correct so I guess the tenant is initialized?My setup is using multi database tenancy
My bootstrappers:
Steps to reproduce
Dispatch a job from a tenant context and log any route using the route helper.
The job class handle method
Logs in the laravel.log file:
Expected behavior
As tenancy()->tenant has the correct tennat I would expect the route helper to use the tenant domain.
Laravel version
10.48.7
stancl/tenancy version
v3.8.1