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