src/Entity/Questions.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuestionsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=QuestionsRepository::class)
  9.  */
  10. class Questions
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, nullable=true)
  20.      */
  21.     private $title;
  22.     /**
  23.      * @ORM\Column(type="text", nullable=true)
  24.      */
  25.     private $description;
  26.     /**
  27.      * @ORM\Column(type="datetime", nullable=true)
  28.      */
  29.     private $createdAt;
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=true)
  32.      */
  33.     private $updatedAt;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="questions")
  36.      */
  37.     private $user;
  38.     /**
  39.      * @ORM\OneToOne(targetEntity=Answer::class, mappedBy="question", cascade={"persist", "remove"})
  40.      */
  41.     private $answer;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=Answer::class, mappedBy="qstn")
  44.      */
  45.     private $answers;
  46.     public function __construct()
  47.     {
  48.         $this->answers = new ArrayCollection();
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getTitle(): ?string
  55.     {
  56.         return $this->title;
  57.     }
  58.     public function setTitle(?string $title): self
  59.     {
  60.         $this->title $title;
  61.         return $this;
  62.     }
  63.     public function getDescription(): ?string
  64.     {
  65.         return $this->description;
  66.     }
  67.     public function setDescription(?string $description): self
  68.     {
  69.         $this->description $description;
  70.         return $this;
  71.     }
  72.     public function getCreatedAt(): ?\DateTimeInterface
  73.     {
  74.         return $this->createdAt;
  75.     }
  76.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  77.     {
  78.         $this->createdAt $createdAt;
  79.         return $this;
  80.     }
  81.     public function getUpdatedAt(): ?\DateTimeInterface
  82.     {
  83.         return $this->updatedAt;
  84.     }
  85.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  86.     {
  87.         $this->updatedAt $updatedAt;
  88.         return $this;
  89.     }
  90.     public function getUser(): ?User
  91.     {
  92.         return $this->user;
  93.     }
  94.     public function setUser(?User $user): self
  95.     {
  96.         $this->user $user;
  97.         return $this;
  98.     }
  99.     public function getAnswer(): ?Answer
  100.     {
  101.         return $this->answer;
  102.     }
  103.     public function setAnswer(?Answer $answer): self
  104.     {
  105.         // unset the owning side of the relation if necessary
  106.         if ($answer === null && $this->answer !== null) {
  107.             $this->answer->setQuestion(null);
  108.         }
  109.         // set the owning side of the relation if necessary
  110.         if ($answer !== null && $answer->getQuestion() !== $this) {
  111.             $answer->setQuestion($this);
  112.         }
  113.         $this->answer $answer;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, Answer>
  118.      */
  119.     public function getAnswers(): Collection
  120.     {
  121.         return $this->answers;
  122.     }
  123.     public function addAnswer(Answer $answer): self
  124.     {
  125.         if (!$this->answers->contains($answer)) {
  126.             $this->answers[] = $answer;
  127.             $answer->setQstn($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeAnswer(Answer $answer): self
  132.     {
  133.         if ($this->answers->removeElement($answer)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($answer->getQstn() === $this) {
  136.                 $answer->setQstn(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141. }