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')]
  16.     private $sports;
  17.     #[ORM\OneToMany(targetEntityAlert::class, mappedBy'trainee')]
  18.     private $alerts;
  19.     #[ORM\ManyToMany(targetEntityCourse::class, inversedBy'traineesFavorites')]
  20.     private $favorites;
  21.     #[ORM\OneToMany(targetEntityBooking::class, mappedBy'trainee')]
  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.     public function __construct()
  28.     {
  29.         parent::__construct();
  30.         $this->sports = new ArrayCollection();
  31.         $this->alerts = new ArrayCollection();
  32.         $this->favorites = new ArrayCollection();
  33.         $this->bookings = new ArrayCollection();
  34.         $this->proFavorites = new ArrayCollection();
  35.         $this->notes = new ArrayCollection();
  36.     }
  37.     public function getBirthDate(): ?\DateTimeInterface
  38.     {
  39.         return $this->birthDate;
  40.     }
  41.     public function setBirthDate(?\DateTimeInterface $birthDate): static
  42.     {
  43.         $this->birthDate $birthDate;
  44.         return $this;
  45.     }
  46.     public function getCountry(): ?string
  47.     {
  48.         return $this->country;
  49.     }
  50.     public function setCountry(string $country): self
  51.     {
  52.         $this->country $country;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection|SportTrainee[]
  57.      */
  58.     public function getSports(): Collection
  59.     {
  60.         return $this->sports;
  61.     }
  62.     public function addSport(SportTrainee $sport): self
  63.     {
  64.         if (!$this->sports->contains($sport)) {
  65.             $this->sports[] = $sport;
  66.             $sport->setTrainee($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeSport(SportTrainee $sport): self
  71.     {
  72.         if ($this->sports->removeElement($sport)) {
  73.             // set the owning side to null (unless already changed)
  74.             if ($sport->getTrainee() === $this) {
  75.                 $sport->setTrainee(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection|Alert[]
  82.      */
  83.     public function getAlerts(): Collection
  84.     {
  85.         return $this->alerts;
  86.     }
  87.     public function addAlert(Alert $alert): self
  88.     {
  89.         if (!$this->alerts->contains($alert)) {
  90.             $this->alerts[] = $alert;
  91.             $alert->setTrainee($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeAlert(Alert $alert): self
  96.     {
  97.         if ($this->alerts->removeElement($alert)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($alert->getTrainee() === $this) {
  100.                 $alert->setTrainee(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection|Course[]
  107.      */
  108.     public function getFavorites(): Collection
  109.     {
  110.         return $this->favorites;
  111.     }
  112.     public function addFavorite(Course $favorite): self
  113.     {
  114.         if (!$this->favorites->contains($favorite)) {
  115.             $this->favorites[] = $favorite;
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeFavorite(Course $favorite): self
  120.     {
  121.         $this->favorites->removeElement($favorite);
  122.         return $this;
  123.     }
  124.     // Check course favorite
  125.     public function isCourseFavorite(Course $course)
  126.     {
  127.         if($course->getTraineesFavorites()->contains($this))
  128.         {
  129.             return true;
  130.         }
  131.     }
  132.     /**
  133.      * @return Collection|Booking[]
  134.      */
  135.     public function getBookings(): Collection
  136.     {
  137.         return $this->bookings;
  138.     }
  139.     public function addBooking(Booking $booking): self
  140.     {
  141.         if (!$this->bookings->contains($booking)) {
  142.             $this->bookings[] = $booking;
  143.             $booking->setTrainee($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeBooking(Booking $booking): self
  148.     {
  149.         if ($this->bookings->removeElement($booking)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($booking->getTrainee() === $this) {
  152.                 $booking->setTrainee(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection|User[]
  159.      */
  160.     public function getProFavorites(): Collection
  161.     {
  162.         return $this->proFavorites;
  163.     }
  164.     public function addProFavorite(User $proFavorite): self
  165.     {
  166.         if (!$this->proFavorites->contains($proFavorite)) {
  167.             $this->proFavorites[] = $proFavorite;
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeProFavorite(User $proFavorite): self
  172.     {
  173.         $this->proFavorites->removeElement($proFavorite);
  174.         return $this;
  175.     }
  176.     // Check pro favorite
  177.     public function isProFavorite(User $user)
  178.     {
  179.         if($user->getTraineesFavorites()->contains($this))
  180.         {
  181.             return true;
  182.         }
  183.     }
  184.     /**
  185.      * @return Collection<int, Note>
  186.      */
  187.     public function getNotes(): Collection
  188.     {
  189.         return $this->notes;
  190.     }
  191.     public function addNote(Note $note): static
  192.     {
  193.         if (!$this->notes->contains($note)) {
  194.             $this->notes->add($note);
  195.             $note->setTrainee($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeNote(Note $note): static
  200.     {
  201.         if ($this->notes->removeElement($note)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($note->getTrainee() === $this) {
  204.                 $note->setTrainee(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209. }