0
votes

I have on my database these 3 tables:

users (model User)

accounts (model Account)

user_accounts (relationship table many to many) (id, user_id, account_id, role_id)

The problem is in the user_accounts I have an additional column role_id the meaning is to invite many users with different access levels.

maybe using $user->accounts()->sync($account, false);

how to save the data in this table maybe using

1
Welcome to SO @broadcast. What have you already tried? Provide code please. - ggdx

1 Answers

0
votes

From the documentation, you can do it as follows:

$user->accounts()->sync([$accountId => ['role_id' => $roleId]], false);