Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

OpenSauceMike's avatar

Add middleware to a modal

I'm building a custom multi tenant setup with multiple databases (landlord plus one per tenant). I have created some middleware that checks for the existence of the tenant in the session and sets the database (either the correct tenant or the landlord if there is no tenant). This works correctly for all normal pages on the site.

However, when I open a modal, e.g. to create a new user, using the standard Filament CreateUser modal, the database instantly changes back to the default which is the landlord.

Can anyone point me in the right direction to either apply my database script to the modals or another way of setting the database?

I have looked the through the stancl/tenancy code and can't seem to work out how it actually switches the databases? Thanks in advance. Mike

0 likes
2 replies

Please or to participate in this conversation.