src/Entity/Trainee.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TraineeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassTraineeRepository::class)]
  9. class Trainee extends User
  10. {
  11.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  12.     private ?\DateTimeInterface $birthDate null;
  13.     #[ORM\Column(type'string'length255)]
  14.     private $country;
  15.     #[ORM\OneToMany(targetEntitySportTrainee::class, mappedBy'trainee'cascade: ['persist''remove'])]
  16.     private $sports;
  17.     #[ORM\OneToMany(targetEntityAlert::class, mappedBy'trainee'cascade: ['persist''remove'])]
  18.     private $alerts;
  19.     #[ORM\ManyToMany(targetEntityCourse::class, inversedBy'traineesFavorites')]
  20.     private $favorites;
  21.     #[ORM\OneToMany(targetEntityBooking::class, mappedBy'trainee'cascade: ['persist''remove'])]
  22.     private $bookings;
  23.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'traineesFavorites')]
  24.     private $proFavorites;
  25.     #[ORM\OneToMany(mappedBy'trainee'targetEntityNote::class)]
  26.     private Collection $notes;
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?bool $showPhone null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?bool $showEmail null;
  31.     public function __construct()
  32.     {
  33.         parent::__construct();
  34.         $this->sports = new ArrayCollection();
  35.         $this->alerts = new ArrayCollection();
  36.         $this->favorites = new ArrayCollection();
  37.         $this->bookings = new ArrayCollection();
  38.         $this->proFavorites = new ArrayCollection();
  39.         $this->notes = new ArrayCollection();
  40.     }
  41.     public function getBirthDate(): ?\DateTimeInterface
  42.     {
  43.         return $this->birthDate;
  44.     }
  45.     public function setBirthDate(?\DateTimeInterface $birthDate): static
  46.     {
  47.         $this->birthDate $birthDate;
  48.         return $this;
  49.     }
  50.     public function getCountry(): ?string
  51.     {
  52.         return $this->country;
  53.     }
  54.     public function setCountry(string $country): self
  55.     {
  56.         $this->country $country;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return Collection|SportTrainee[]
  61.      */
  62.     public function getSports(): Collection
  63.     {
  64.         return $this->sports;
  65.     }
  66.     public function addSport(SportTrainee $sport): self
  67.     {
  68.         if (!$this->sports->contains($sport)) {
  69.             $this->sports[] = $sport;
  70.             $sport->setTrainee($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeSport(SportTrainee $sport): self
  75.     {
  76.         if ($this->sports->removeElement($sport)) {
  77.             // set the owning side to null (unless already changed)
  78.             if ($sport->getTrainee() === $this) {
  79.                 $sport->setTrainee(null);
  80.             }
  81.         }
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|Alert[]
  86.      */
  87.     public function getAlerts(): Collection
  88.     {
  89.         return $this->alerts;
  90.     }
  91.     public function addAlert(Alert $alert): self
  92.     {
  93.         if (!$this->alerts->contains($alert)) {
  94.             $this->alerts[] = $alert;
  95.             $alert->setTrainee($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeAlert(Alert $alert): self
  100.     {
  101.         if ($this->alerts->removeElement($alert)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($alert->getTrainee() === $this) {
  104.                 $alert->setTrainee(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection|Course[]
  111.      */
  112.     public function getFavorites(): Collection
  113.     {
  114.         return $this->favorites;
  115.     }
  116.     public function addFavorite(Course $favorite): self
  117.     {
  118.         if (!$this->favorites->contains($favorite)) {
  119.             $this->favorites[] = $favorite;
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeFavorite(Course $favorite): self
  124.     {
  125.         $this->favorites->removeElement($favorite);
  126.         return $this;
  127.     }
  128.     // Check course favorite
  129.     public function isCourseFavorite(Course $course)
  130.     {
  131.         if($course->getTraineesFavorites()->contains($this))
  132.         {
  133.             return true;
  134.         }
  135.     }
  136.     /**
  137.      * @return Collection|Booking[]
  138.      */
  139.     public function getBookings(): Collection
  140.     {
  141.         return $this->bookings;
  142.     }
  143.     public function addBooking(Booking $booking): self
  144.     {
  145.         if (!$this->bookings->contains($booking)) {
  146.             $this->bookings[] = $booking;
  147.             $booking->setTrainee($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeBooking(Booking $booking): self
  152.     {
  153.         if ($this->bookings->removeElement($booking)) {
  154.             // set the owning side to null (unless already changed)
  155.             if ($booking->getTrainee() === $this) {
  156.                 $booking->setTrainee(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     /**
  162.      * @return Collection|User[]
  163.      */
  164.     public function getProFavorites(): Collection
  165.     {
  166.         return $this->proFavorites;
  167.     }
  168.     public function addProFavorite(User $proFavorite): self
  169.     {
  170.         if (!$this->proFavorites->contains($proFavorite)) {
  171.             $this->proFavorites[] = $proFavorite;
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeProFavorite(User $proFavorite): self
  176.     {
  177.         $this->proFavorites->removeElement($proFavorite);
  178.         return $this;
  179.     }
  180.     // Check pro favorite
  181.     public function isProFavorite(User $user)
  182.     {
  183.         if($user->getTraineesFavorites()->contains($this))
  184.         {
  185.             return true;
  186.         }
  187.     }
  188.     /**
  189.      * @return Collection<int, Note>
  190.      */
  191.     public function getNotes(): Collection
  192.     {
  193.         return $this->notes;
  194.     }
  195.     public function addNote(Note $note): static
  196.     {
  197.         if (!$this->notes->contains($note)) {
  198.             $this->notes->add($note);
  199.             $note->setTrainee($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeNote(Note $note): static
  204.     {
  205.         if ($this->notes->removeElement($note)) {
  206.             // set the owning side to null (unless already changed)
  207.             if ($note->getTrainee() === $this) {
  208.                 $note->setTrainee(null);
  209.             }
  210.         }
  211.         return $this;
  212.     }
  213.     public function getShowPhone(): ?bool
  214.     {
  215.         return $this->showPhone;
  216.     }
  217.     public function setShowPhone(?bool $showPhone): static
  218.     {
  219.         $this->showPhone $showPhone;
  220.         return $this;
  221.     }
  222.     public function getShowEmail(): ?bool
  223.     {
  224.         return $this->showEmail;
  225.     }
  226.     public function setShowEmail(?bool $showEmail): static
  227.     {
  228.         $this->showEmail $showEmail;
  229.         return $this;
  230.     }
  231. }