I am using stancl/tenancy im project, but I can not find a method in documentation which could iterate over all tenants and switch to current tenant in iteration. Is there something like that? For example Laravel/Multitenancy package has Tenant::all()->eachCurrent() method which do exactly what I need.
This can be achieved using the run()
method. For example to dump all users for all tenants:
Tenant::all()->each( function($tenant) {
$tenant->run(function () {
// This will be run in the tenant context
dump(User::all());
});
});