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