src/Entity/Respondent.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RespondentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Table(name="respondent")
  10.  * @ORM\Entity(repositoryClass=RespondentRepository::class)
  11.  */
  12. class Respondent
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="datetime_immutable")
  22.      */
  23.     private $startTime;
  24.     /**
  25.      * @ORM\Column(type="datetime_immutable", nullable=true)
  26.      */
  27.     private $endTime;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=Rank::class, inversedBy="respondents")
  30.      * @ORM\JoinColumn(nullable=false)
  31.      */
  32.     private $rank;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity=Answer::class, mappedBy="respondent", orphanRemoval=true)
  35.      */
  36.     private $answers;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=RespondentTraining::class, mappedBy="respondent")
  39.      * @ORM\OrderBy({"priorityOrder" = "ASC"})
  40.      */
  41.     private $respondentTrainings;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="respondents")
  44.      * @ORM\JoinColumn(nullable=false)
  45.      */
  46.     private $user;
  47.     /**
  48.      * @ORM\Column(length=128, unique=true)
  49.      * @Gedmo\Slug(fields={"startTime"}, style="lower", separator="", updatable=false, unique=true, dateFormat="YmdHisu")
  50.      */
  51.     private $slug;
  52.     public function __construct()
  53.     {
  54.         $this->answers = new ArrayCollection();
  55.         $this->respondentTrainings = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     /**
  62.      * Getter pour le lastName de l'utilisateur liĆ©
  63.      */
  64.     public function getUserLastName(): ?string
  65.     {
  66.         return $this->user $this->user->getLastName() : null;
  67.     }
  68.     public function getStartTime(): ?\DateTimeImmutable
  69.     {
  70.         return $this->startTime;
  71.     }
  72.     public function setStartTime(\DateTimeImmutable $startTime): self
  73.     {
  74.         $this->startTime $startTime;
  75.         return $this;
  76.     }
  77.     public function getEndTime(): ?\DateTimeImmutable
  78.     {
  79.         return $this->endTime;
  80.     }
  81.     public function setEndTime(?\DateTimeImmutable $endTime): self
  82.     {
  83.         $this->endTime $endTime;
  84.         return $this;
  85.     }
  86.     public function getRank(): ?Rank
  87.     {
  88.         return $this->rank;
  89.     }
  90.     public function setRank(?Rank $rank): self
  91.     {
  92.         $this->rank $rank;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return Collection<int, Answer>
  97.      */
  98.     public function getAnswers(): Collection
  99.     {
  100.         return $this->answers;
  101.     }
  102.     public function addAnswer(Answer $answer): self
  103.     {
  104.         if (!$this->answers->contains($answer)) {
  105.             $this->answers[] = $answer;
  106.             $answer->setRespondent($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removeAnswer(Answer $answer): self
  111.     {
  112.         if ($this->answers->removeElement($answer)) {
  113.             // set the owning side to null (unless already changed)
  114.             if ($answer->getRespondent() === $this) {
  115.                 $answer->setRespondent(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, RespondentTraining>
  122.      */
  123.     public function getRespondentTrainings(): Collection
  124.     {
  125.         return $this->respondentTrainings;
  126.     }
  127.     public function addRespondentTraining(RespondentTraining $respondentTraining): self
  128.     {
  129.         if (!$this->respondentTrainings->contains($respondentTraining)) {
  130.             $this->respondentTrainings[] = $respondentTraining;
  131.             $respondentTraining->setRespondent($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeRespondentTraining(RespondentTraining $respondentTraining): self
  136.     {
  137.         if ($this->respondentTrainings->removeElement($respondentTraining)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($respondentTraining->getRespondent() === $this) {
  140.                 $respondentTraining->setRespondent(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     public function getUser(): ?User
  146.     {
  147.         return $this->user;
  148.     }
  149.     public function setUser(?User $user): self
  150.     {
  151.         $this->user $user;
  152.         return $this;
  153.     }
  154.     public function getSlug(): ?string
  155.     {
  156.         return $this->slug;
  157.     }
  158. }