src/Entity/Coach.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CoachRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCoachRepository::class)]
  8. class Coach
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\ManyToOne(targetEntityPerson::class, inversedBy'coaches')]
  15.     #[ORM\JoinColumn(nullablefalse)]
  16.     private $person;
  17.     #[ORM\ManyToOne(targetEntitySeason::class, inversedBy'coaches')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private $season;
  20.     #[ORM\ManyToMany(targetEntitySlot::class, mappedBy'coachs')]
  21.     private $slots;
  22.     public function __construct()
  23.     {
  24.         $this->slots = new ArrayCollection();
  25.     }
  26.     public function __toString(): string
  27.     {
  28.         return sprintf(
  29.             '%s - %s',
  30.             $this->getSeason()?->getSection()?->getName(),
  31.             $this->getPerson()?->getFullName(true)
  32.         );
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getPerson(): ?Person
  39.     {
  40.         return $this->person;
  41.     }
  42.     public function setPerson(?Person $person): self
  43.     {
  44.         $this->person $person;
  45.         return $this;
  46.     }
  47.     public function getSeason(): ?Season
  48.     {
  49.         return $this->season;
  50.     }
  51.     public function setSeason(?Season $season): self
  52.     {
  53.         $this->season $season;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, Slot>
  58.      */
  59.     public function getSlots(): Collection
  60.     {
  61.         return $this->slots;
  62.     }
  63.     public function addSlot(Slot $slot): self
  64.     {
  65.         if (!$this->slots->contains($slot)) {
  66.             $this->slots[] = $slot;
  67.             $slot->addCoach($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeSlot(Slot $slot): self
  72.     {
  73.         if ($this->slots->removeElement($slot)) {
  74.             $slot->removeCoach($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function __clone()
  79.     {
  80.         $this->id null;
  81.         $this->season null;
  82.         $this->slots = new ArrayCollection();
  83.     }
  84. }