<?phpnamespace App\Entity;use App\Repository\CoachRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CoachRepository::class)]class Coach{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'coaches')] #[ORM\JoinColumn(nullable: false)] private $person; #[ORM\ManyToOne(targetEntity: Season::class, inversedBy: 'coaches')] #[ORM\JoinColumn(nullable: false)] private $season; #[ORM\ManyToMany(targetEntity: Slot::class, mappedBy: 'coachs')] private $slots; public function __construct() { $this->slots = new ArrayCollection(); } public function __toString(): string { return sprintf( '%s - %s', $this->getSeason()?->getSection()?->getName(), $this->getPerson()?->getFullName(true) ); } public function getId(): ?int { return $this->id; } public function getPerson(): ?Person { return $this->person; } public function setPerson(?Person $person): self { $this->person = $person; return $this; } public function getSeason(): ?Season { return $this->season; } public function setSeason(?Season $season): self { $this->season = $season; return $this; } /** * @return Collection<int, Slot> */ public function getSlots(): Collection { return $this->slots; } public function addSlot(Slot $slot): self { if (!$this->slots->contains($slot)) { $this->slots[] = $slot; $slot->addCoach($this); } return $this; } public function removeSlot(Slot $slot): self { if ($this->slots->removeElement($slot)) { $slot->removeCoach($this); } return $this; } public function __clone() { $this->id = null; $this->season = null; $this->slots = new ArrayCollection(); }}