src/Entity/Survey/UserAnswer.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Survey;
  4. use App\Entity\Creator;
  5. use App\Services\Survey\Repository\UserAnswerRepository;
  6. use DateTimeImmutable;
  7. use Doctrine\ORM\Mapping\Column;
  8. use Doctrine\ORM\Mapping\Entity;
  9. use Doctrine\ORM\Mapping\GeneratedValue;
  10. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  11. use Doctrine\ORM\Mapping\Id;
  12. use Doctrine\ORM\Mapping\ManyToOne;
  13. use Doctrine\ORM\Mapping\PrePersist;
  14. use Doctrine\ORM\Mapping\PreUpdate;
  15. #[Entity(UserAnswerRepository::class)]
  16. #[HasLifecycleCallbacks]
  17. class UserAnswer
  18. {
  19.     #[Id]
  20.     #[GeneratedValue]
  21.     #[Column('id''bigint'options: ['unsigned' => true])]
  22.     private int $id;
  23.     #[ManyToOne(targetEntityCreator::class)]
  24.     private Creator $creator;
  25.     #[ManyToOne(targetEntityQuestion::class)]
  26.     private Question $question;
  27.     #[ManyToOne(targetEntityAnswer::class)]
  28.     private ?Answer $answer null;
  29.     #[Column(type'text')]
  30.     private ?string $answerText null;
  31.     #[Column(name'created_at'type'datetime_immutable')]
  32.     private ?DateTimeImmutable $createdAt null;
  33.     #[Column(name'updated_at'type'datetime_immutable'nullabletrue)]
  34.     private ?DateTimeImmutable $updatedAt null;
  35.     #[PrePersist]
  36.     public function prePersist(): void
  37.     {
  38.         $this->createdAt = new DateTimeImmutable();
  39.     }
  40.     #[PreUpdate]
  41.     public function preUpdate(): void
  42.     {
  43.         $this->updatedAt = new DateTimeImmutable();
  44.     }
  45.     public function getId(): int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function setId(int $id): void
  50.     {
  51.         $this->id $id;
  52.     }
  53.     public function getCreator(): Creator
  54.     {
  55.         return $this->creator;
  56.     }
  57.     public function setCreator(Creator $creator): void
  58.     {
  59.         $this->creator $creator;
  60.     }
  61.     public function getQuestion(): Question
  62.     {
  63.         return $this->question;
  64.     }
  65.     public function setQuestion(Question $question): void
  66.     {
  67.         $this->question $question;
  68.     }
  69.     public function getAnswer(): ?Answer
  70.     {
  71.         return $this->answer;
  72.     }
  73.     public function setAnswer(?Answer $answer): void
  74.     {
  75.         $this->answer $answer;
  76.     }
  77.     public function getAnswerText(): ?string
  78.     {
  79.         return $this->answerText;
  80.     }
  81.     public function setAnswerText(?string $answerText): void
  82.     {
  83.         $this->answerText $answerText;
  84.     }
  85.     public function getCreatedAt(): ?DateTimeImmutable
  86.     {
  87.         return $this->createdAt;
  88.     }
  89.     public function setCreatedAt(?DateTimeImmutable $createdAt): void
  90.     {
  91.         $this->createdAt $createdAt;
  92.     }
  93.     public function getUpdatedAt(): ?DateTimeImmutable
  94.     {
  95.         return $this->updatedAt;
  96.     }
  97.     public function setUpdatedAt(?DateTimeImmutable $updatedAt): void
  98.     {
  99.         $this->updatedAt $updatedAt;
  100.     }
  101. }