I have a priority column in my pivot, as each item gets added to the intermediate table, the priority is always set to the max priority + 1, but when removing an intermediate row, i need to renumber the existing records. I am trying to do it like this, but they are not getting updated:
$service->voipRateGroups()->detach($rateGroup->id);
$service
->voipRateGroups()
->wherePivot('priority', '>', $priority)
->each(function ($vrg) use ($service){
$newPriority = $vrg->pivot->priority -1;
$service
->voipRateGroups()
->updateExistingPivot($vrg->voip_rate_group_id, ['priority' => $newPriority]);
});