/** * Filters contributions for unique participants * * @param Challenge $challenge * @return ArrayCollection */ protected function getUniqueParticipants($challenge) { //Filter duplicated participants $participants = new ArrayCollection(); $challenge->getContributions()->map(function ($c) use($participants) { if (!$participants->contains($c->getUserId())) { $participants->add($c->getUserId()); } }); return $participants; }