laravel update many field relation code example Example: laravel many to many relation update $user->roles()->sync([1, 2, 3]);