This is contrary to what you were doing with the collection to array approach. Since you were using `$user->learningSkills`, you need the collection you are iterating over to be of `User` objects, or you need to alter how `User` objects are serialized to arrays to include the `learning_skills` and `teaching_skills` data, which it does not currently.