multi-tenancy - tenant relationship on every single table?
I know I've seen somewhere in the documentation or online where you don't have to have the tenant relationship on every single table. For example, if the parent already has the tenant relationship, then the child table doesn't need it. I have a
locations
table that has the team_id
and then a vendors
table that has a location_id
. How can I attribute the vendor to the team indirectly through the locations table without defining a team_id
FK on the vendors table?Solution:Jump to solution
Is this a case of using "hasOneThrough" or "hasManyThrough"? I haven't hit this exact situation, but it feels about right. https://laravel.com/docs/10.x/eloquent-relationships#has-many-through
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
2 Replies
Solution
Is this a case of using "hasOneThrough" or "hasManyThrough"? I haven't hit this exact situation, but it feels about right. https://laravel.com/docs/10.x/eloquent-relationships#has-many-through
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
yep, that seems to be the fix, thx!