I have 2 objects, namely Match and Team. A team can have one, many matches. However, my Match entity consts consists of 2 fields that reference the same Team object. These are $ homeTeam and $ awayTeam. How do I refer to the same field in teams, $ match, as a bi-directional relationship?
My current broken code is below:
My Match Entity:
/** * @ORM\Entity * @ORM\Table(name="match") **/ class Match { /** * @ORM\ManyToOne(targetEntity="Team", inversedBy="matches") * @ORM\JoinColumn(name="home_team_id", referencedColumnName="id") * **/ protected $homeTeam; /** * @ORM\ManyToOne(targetEntity="Team", inversedBy="matches") * @ORM\JoinColumn(name="away_team_id", referencedColumnName="id") * **/ protected $awayTeam;
My team entity (am I guessing wrong?):
class Team { protected $matches;
Blyde
source share