api-platform / api-platform/core
[Laravel] Multi-tenancy support
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 980
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 48
Description
**Description**
I would like to use API Platform alongside the [Tenancy](https://tenancyforlaravel.com/) package. The [concept](https://tenancyforlaravel.com/docs/v3/the-two-applications) behind Tenancy is simple. There are two types of databases (applications):
- A central database, which stores the list of all tenants (along with other non-tenant-dependent data).
- Multiple tenant databases, where tenant-specific data is stored.
Based on the request, we determine which database should be used for tenant-specific models. And here lies the problem: API Platform only recognizes the structure of the central database at startup and caches the model attributes. As a result, it cannot find the attributes for tenant models.
It seems to work only if the tenant database is a subset of the central database. This means I need to generate all tenant tables in the central database as well and then switch to the tenant database at request time. However, this feels more like a workaround rather than an ideal solution.
Contributor guide
Assessment
This issue has not been assessed yet.