mercredi 16 décembre 2015

How to trigger code before and after queues in laravel 5?

I am trying to work on a multi tenant multi database application which basically means that every tenant has its own database, own users, resources etc.

Naturally when a request comes in, Laravel needs to know which DB connection to use so I wrote a middleware which basically parses the JWT in the requests and looks for the tenant id or username then simply connects to the tenant's database.

This works well for requests but now I am stuck with queues. I am trying to run queues for tenants like for sending emails, but before even firing the handle method, laravel tries to fetch the user from the default Db and fails or fetches the wrong user of course.

Is there a way to call code before a queue handle method fires off? Is there a before and after method for laravel queues that I don't know about?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire