Should the role_user pivot table also have ...
No, the pivot table must have only the keys from the 2 original tables.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am walking through the multi-tenant series, and I have a question about a pivot table in a multi-tenant setup. Since the pivot table is just the link between two tables, do I need a tenant_id on the pivot table?
For example, if I have a users table and roles table there is a many to many relationship. The users table has a tenant_id and the roles table has a tenant_id. Should the role_user pivot table also have the tenant_id field? Or can I assumed that since the users and roles table has the BelongsToTenant trait and corresponding tenant_id field that it cascades through to the pivot table?
Please or to participate in this conversation.