Skip to content

[4.x] Route name prefixing and tenant parameter passing #252

@lukinovec

Description

@lukinovec

When using path or query string identification with other packages, the links retrieved by route() (e.g. Jetstream views) or temporarySignedRoute() (e.g. Livewire file uploads) in tenant context don't get the tenant parameter – they point to the central app (e.g. 'app.test/home' instead of 'app.test/{tenant}/home'). By enabling UrlBindingBootstrapper, we can deal with that by overriding the UrlGenerator instance with our custom generator (TenancyUrlGenerator).

The custom generator has the $prefixRouteNames static property which toggles prefixing of route names passed to route() (e.g. route('foo') calls route('tenant.foo') when $prefixRouteNames is true).

You can also pass the bypass parameter (route('foo', ['central' => true]); the bypass parameter is 'central' by default) to skip overriding the mentioned methods.

Edge case: when using path identification in the global stack, you'll need to use the custom generator, but you might also want to use a different identification method on the route level (for example, domain identification). The links you see when visiting the route will be broken – they will link to 'app.test/{tenant}/home' instead of 'tenant-domain.test/home'.

https://discord.com/channels/976506366502006874/976513756576243733/1131092283975008326

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions