src/Entity/Coach.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\User;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Repository\CoachRepository;
  8. #[ORM\Entity(repositoryClassCoachRepository::class)]
  9. class Coach extends User
  10. {
  11.     #[ORM\OneToOne(targetEntityCoachInfo::class, mappedBy'owner'cascade: ['persist''remove'])]
  12.     private $coachInfo;
  13.     #[ORM\Column(type'boolean'nullabletrueoptions: ['default' => true])]
  14.     private $isMobile true;
  15.     #[ORM\OneToMany(targetEntityClubInfo::class, mappedBy'createdByCoach')]
  16.     private Collection $createdClubInfos;
  17.     #[ORM\OneToMany(targetEntityPartnership::class, mappedBy'coach')]
  18.     private $partnerships;
  19.     public function __construct()
  20.     {
  21.         $this->createdClubInfos = new ArrayCollection();
  22.         $this->partnerships = new ArrayCollection();
  23.     }
  24.     public function getCoachInfo(): ?CoachInfo
  25.     {
  26.         return $this->coachInfo;
  27.     }
  28.     public function setCoachInfo(?CoachInfo $coachInfo): self
  29.     {
  30.         // unset the owning side of the relation if necessary
  31.         if ($coachInfo === null && $this->coachInfo !== null) {
  32.             $this->coachInfo->setOwner(null);
  33.         }
  34.         // set the owning side of the relation if necessary
  35.         if ($coachInfo !== null && $coachInfo->getOwner() !== $this) {
  36.             $coachInfo->setOwner($this);
  37.         }
  38.         $this->coachInfo $coachInfo;
  39.         return $this;
  40.     }
  41.     public function getIsMobile(): ?bool
  42.     {
  43.         return $this->isMobile;
  44.     }
  45.     public function setIsMobile(bool $isMobile): self
  46.     {
  47.         $this->isMobile $isMobile;
  48.         return $this;
  49.     }
  50.     public function getCreatedClubInfos(): Collection
  51.     {
  52.         return $this->createdClubInfos;
  53.     }
  54.     public function addCreatedClubInfo(ClubInfo $clubInfo): self
  55.     {
  56.         if (!$this->createdClubInfos->contains($clubInfo)) {
  57.             $this->createdClubInfos[] = $clubInfo;
  58.             $clubInfo->setCreatedByCoach($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeCreatedClubInfo(ClubInfo $clubInfo): self
  63.     {
  64.         if ($this->createdClubInfos->removeElement($clubInfo)) {
  65.             if ($clubInfo->getCreatedByCoach() === $this) {
  66.                 $clubInfo->setCreatedByCoach(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection|Partnership[]
  73.      */
  74.     public function getPartnerships(): Collection
  75.     {
  76.         return $this->partnerships;
  77.     }
  78.     public function addPartnership(Partnership $partnership): self
  79.     {
  80.         if (!$this->partnerships->contains($partnership)) {
  81.             $this->partnerships[] = $partnership;
  82.             $partnership->setCoach($this);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removePartnership(Partnership $partnership): self
  87.     {
  88.         if ($this->partnerships->removeElement($partnership)) {
  89.             // set the owning side to null (unless already changed)
  90.             if ($partnership->getCoach() === $this) {
  91.                 $partnership->setCoach(null);
  92.             }
  93.         }
  94.         return $this;
  95.     }
  96. }