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