spatie/laravel-multitenancy
Unopinionated multitenancy for Laravel. Detect the current tenant per request and run configurable tasks when switching tenants. Supports single or multiple databases, tenant-aware queued jobs, per-tenant Artisan commands, and easy model connection handling.
Processing a job no longer leaves the surrounding code with a different current tenant than it had before (#639, #643).
On the sync connection and through dispatchSync(), a job runs inside the request that dispatched it. A job that is not tenant aware forgot the current tenant and never put it back, so the rest of the request continued without one. A tenant aware job for another tenant left that other tenant current. Whatever tenant was current before a job starts is now restored when it finishes, on both the success and the failure path, and nested sync dispatches restore per level.
queue:retry behaves the same way. It needs the tenant of a failed job while it pushes that job back onto the queue, but the tenant of the code that ran the command is restored once it finishes. This matters when retrying jobs from a request with Artisan::call('queue:retry').
Behaviour worth knowing about when upgrading: on a queue worker the tenant of a processed job no longer stays current after that job finishes. Every job binds its own tenant, so jobs are unaffected, but code reading Tenant::current() in between jobs now sees no tenant. Listeners that are part of processing a job, Queue::after() and JobFailed for instance, still see the tenant of the job they are handling.
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.5...4.2.0
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.4...4.1.5
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.3...4.1.4
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.2...4.1.3
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.1...4.1.2
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.1.0...4.1.1
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.8...4.0.9
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.6...4.0.7
TenantAware by @SethSharp in https://github.com/spatie/laravel-multitenancy/pull/602TenantAware and NotTenantAware interfaces by @przemyslaw-przylucki in https://github.com/spatie/laravel-multitenancy/pull/607Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.5...4.0.6
ShouldBeEncrypted need to be decrypted by @Joel-Jensen in https://github.com/spatie/laravel-multitenancy/pull/588Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.4...4.0.5
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.3...4.0.4
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.2...4.0.3
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.1...4.0.2
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/4.0.0...4.0.1
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.2.0...4.0.0
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.1.1...3.2.0
TenantNotFoundForRequestEvent by @jacobmllr95 in https://github.com/spatie/laravel-multitenancy/pull/502Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.1.0...3.1.1
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.0.3...3.1.0
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.0.2...3.0.3
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.0.1...3.0.2
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/3.0.0...3.0.1
NotTenantAware jobs will now forget any current tenant that might have been set when starting processing.Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.9...3.0.0
Illuminate\Cache\Repository was not being cleared from the containerFull Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.8...2.3.9
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.7...2.3.8
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.6...2.3.7
Tenant class from self to static by @ksassnowski in https://github.com/spatie/laravel-multitenancy/pull/365Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.5...2.3.6
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.4...2.3.5
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.3...2.4.0
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.2...2.3.3
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.3.0...2.3.1
Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.2.0...2.3.0
JobRetryRequested queue event and fix #259 by @aginev in https://github.com/spatie/laravel-multitenancy/pull/298Full Changelog: https://github.com/spatie/laravel-multitenancy/compare/2.1.1...2.2.0
How can I help you explore Laravel packages today?