-
-
Notifications
You must be signed in to change notification settings - Fork 153
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating route using route() #65
Comments
Hi @ivalkenburg, you need a task to switch your URL. Try with it: class SwitchRouteUrlTask implements SwitchTenantTask
{
private $originalUrl;
public function makeCurrent(Tenant $tenant): void
{
$this->originalUrl = config('app.url');
$protocol = Str::before($this->originalUrl, '://');
Config::set('app.url', "{$protocol}://{$tenant->domain}");
URL::forceRootUrl(config('app.url'));
}
public function forgetCurrent(): void
{
Config::set('app.url', $this->originalUrl);
URL::forceRootUrl($this->originalUrl);
}
} |
Thanks, this seems to work great. |
@ivalkenburg ok, if the problem has been solved, please close the issue. Thanks :) |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When generating routes using route() helper inside a queued job or mail, it will generate the non scoped route. For example: tenant is acme with the domain acme.localhost and I will send a user a password recovery email implementing ShouldQueue with a link inside the mail/notification using the route helper function. The route helper will actually return the route using the root domain (localhost) instead of acme.localhost because of how the routes are setup.
So my question is if there is any elegant way to handle this problem without having to write my own UrlGenerator implementation and instead use a switch task?
The text was updated successfully, but these errors were encountered: