Jun 30, 2017
0
Level 2
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')
Please or to participate in this conversation.