In my Badges Entity, I have this manytomany association:
<?php
class Badges
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false, unique=true)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Unidirectional - Many users have Many new Matches (OWNING SIDE)
*
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Entity\Event", cascade={"persist"})
*/
private $match;
}
Which takes an event and associate it to this badge. Many badges can have many events. That's ok.
Now my problem is that a Badge can have several time the same event. And doctrine 2 Does NOT like that and throw out an error. Something like "This relation (Badge_id - Event_id ) already exist.
How do I fix that ?
Many thanks