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

FutureWeb's avatar

Laravel 11 Jetstream customise pivot

Hi LaraPeeps !

I am trying to figure out how to update the role column in team_user to a json column "roles" so a user can have many roles.

My schema looks like this:

Anyway long and the short of it all my tests pass except 2

in the Team model I have the following method:

public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'team_user')
            ->withPivot('roles') // Reference the roles column
            ->withTimestamps();
    }

I assume I need override jetstreams controller somehow but since laravel 11 these seem to be somewhere in the vendor files but I am sure they can be extended in some way I just don't know how?

0 likes
1 reply
Tray2's avatar

If I were you, I'd really ask myself if it was a good idea to use a json column for something that is clearly a relationship, and as you state a many to many. You really should stick with a regular pivot table rather than doing something as "stupid" as using a json column to store relational values.

Harness the power of the RDBMS.

Please or to participate in this conversation.