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