Skip to content
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

Querying tenant models with the Concurrency facade #574

Open
IronSinew opened this issue Dec 23, 2024 · 0 comments
Open

Querying tenant models with the Concurrency facade #574

IronSinew opened this issue Dec 23, 2024 · 0 comments

Comments

@IronSinew
Copy link

Relevant context: https://laravel.com/docs/11.x/concurrency

When I attempted to use Concurrency::run() it failed as the threads did not have the context of the current tenant anymore. Is there a way to ensure that tenancy context is provided to the concurrency facade? Has anyone had any luck doing that?

For example:

        // presumed that the Tenant has already been made current in scope
        [$countUsers, $countPatients] = \Concurrency::run([
            User::count(),
            Patient::count(),
        ]);

        dd($countUsers, $countPatients);

Provided you have two models that have the traits UsesTenantConnection This code above fails to query as my tenant connection has no database by default, so, that empty database does not exist.

The queries work just fine outside of the concurrency facade in this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant