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:
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.
Jump to solution
2 Replies
Solution
Jeff
Jeff14mo ago
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.
Jon Mason
Jon MasonOP14mo ago
yep, that seems to be the fix, thx!
Want results from more Discord servers?
Add your server