Clone an Eloquent object including all relationships?
问题 Is there any way to easily clone an Eloquent object, including all of its relationships? For example, if I had these tables: users ( id, name, email ) roles ( id, name ) user_roles ( user_id, role_id ) In addition to creating a new row in the users table, with all columns being the same except id , it should also create a new row in the user_roles table, assigning the same role to the new user. Something like this: $user = User::find(1); $new_user = $user->clone(); Where the User model has