mirror of
https://github.com/archtechx/tenancy.git
synced 2026-08-06 03:54:04 +00:00
Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
`TriggerSyncingEvents` registered the pivot attach listener on `saved`, which fires on both inserts and updates. So updating pivot columns on a `TenantPivot` (e.g. via `updateExistingPivot()`) re-ran the attach flow and tried to create the tenant resource again, causing a duplicate entry error. Switched the listener to `created` so we only attach when the pivot record is first created (detaching already uses `deleting`, so using `created` makes things a bit more consistent). Added a regression test before the fix (https://github.com/archtechx/tenancy/pull/1469/commits/5e3eb4322cc487d540796317e813ac2ffe076646). The fix (https://github.com/archtechx/tenancy/pull/1469/commits/d2fb4bc0d524cd98ec680e973b791f475afc3548) then made the test pass. Also improved the `saving` listener's comment a bit so that it's clear where the "central resource not available" exception actually comes from, since that wasn't obvious (also added the `@throws` annotation to `getCentralResourceAndTenant()`). Closes #1467 |
||
|---|---|---|
| .github | ||
| art | ||
| assets | ||
| doctum | ||
| extensions | ||
| src | ||
| tests | ||
| typedefs | ||
| .gitattributes | ||
| .gitignore | ||
| .nvim.lua | ||
| .php-cs-fixer.php | ||
| CLAUDE.md | ||
| composer.json | ||
| CONTRIBUTING.md | ||
| docker-compose-m1.override.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| DONATIONS.md | ||
| INTERNAL.md | ||
| LICENSE | ||
| phpstan.neon | ||
| phpunit.xml | ||
| README.md | ||
| static_properties.nu | ||
| SUPPORT.md | ||
| t | ||
| test | ||
Tenancy for Laravel — stancl/tenancy
Automatic multi-tenancy for your Laravel app.
You won't have to change a thing in your application's code.
- ✔️ No model traits to change database connection
- ✔️ No replacing of Laravel classes (
Cache,Storage, ...) with tenancy-aware classes - ✔️ Built-in tenant identification based on hostname (including second level domains)
Documentation
Documentation can be found here: https://v4.tenancyforlaravel.com
Need help?
Credits
- Package created by Samuel Štancl
- Design help & current logo by Florian Karsten
