Fix ignored ids for belongsToMany relations

Fix ids ignored by marshaller for belongsToMany relations.
Needs to be `foreach (`.