Laravel - Relationships - Updating A Record On The Intermediate Table
If you need to update an existing row in your relationship's intermediate table, you may use the updateExistingPivot
method. This method accepts the intermediate record foreign key and an array of attributes to update:
$user = User::find(1);
$user->roles()->updateExistingPivot($roleId, [
'active' => false,
]);