Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

huskeyweb's avatar

How to add extra pivot table attributes to the team_users table

Spark uses a pivot table called team_users that has the following columns:

team_id, user_id, role

I have added a fourth column called "active".

I can access the user's role on their current team like this:

Auth::user()->current_team->pivot->role

What do I need to do to access the "active" column in the same way?

Like this:

Auth::user()->current_team->pivot->active

I'm assuming there is a belongsToMany relationship where I need to add extra attributes like this but I can't find it:

->withPivot('active')

0 likes
0 replies

Please or to participate in this conversation.