src/Entity/Gos/Uniqskills/Answer.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * @ORM\Table()
  9.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\AnswerRepository")
  10.  * @ORM\HasLifecycleCallbacks
  11.  */
  12. class Answer
  13. {
  14.     /**
  15.      * @var integer
  16.      *
  17.      * @ORM\Column(type="integer")
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="text")
  24.      */
  25.     private $name;
  26.     /**
  27.      * @Gedmo\Slug(fields={"name"})
  28.      * @ORM\Column(type="string", length=191, unique=true)
  29.      */
  30.     private $slug;
  31.     /**
  32.      * @var bool
  33.      * @ORM\Column(type="boolean")
  34.      */
  35.     private $isTrue;
  36.     /**
  37.      * @var \DateTime
  38.      *
  39.      * @ORM\Column(type="datetime", nullable=true)
  40.      */
  41.     private $createdAt;
  42.     /**
  43.      * @var \DateTime
  44.      *
  45.      * @ORM\Column(type="datetime", nullable=true)
  46.      */
  47.     private $updatedAt;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity="Question", inversedBy="answer")
  50.      * @ORM\JoinColumn(name="question_id", referencedColumnName="id", onDelete="CASCADE")
  51.      */
  52.     private $question;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity="UserAnswer", mappedBy="answer")
  55.      */
  56.     private $userAnswer;
  57.     /** @ORM\PrePersist() */
  58.     public function prePersist()
  59.     {
  60.         $this->createdAt = new \DateTime();
  61.     }
  62.     /** @ORM\PreUpdate() */
  63.     public function preUpdate()
  64.     {
  65.         $this->updatedAt = new \DateTime();
  66.     }
  67.     public function __toString()
  68.     {
  69.         return (string) $this->name;
  70.     }
  71.     /**
  72.      * Constructor
  73.      */
  74.     public function __construct()
  75.     {
  76.         $this->clientAnswer = new \Doctrine\Common\Collections\ArrayCollection();
  77.         $this->userAnswer = new ArrayCollection();
  78.     }
  79.     public function __clone()
  80.     {
  81.         $this->id           null;
  82.         $this->updatedAt    null;
  83.     }
  84.     public function getId(): ?int
  85.     {
  86.         return $this->id;
  87.     }
  88.     public function getName(): ?string
  89.     {
  90.         return $this->name;
  91.     }
  92.     public function setName(string $name): self
  93.     {
  94.         $this->name $name;
  95.         return $this;
  96.     }
  97.     public function getSlug(): ?string
  98.     {
  99.         return $this->slug;
  100.     }
  101.     public function setSlug(string $slug): self
  102.     {
  103.         $this->slug $slug;
  104.         return $this;
  105.     }
  106.     public function getIsTrue(): ?bool
  107.     {
  108.         return $this->isTrue;
  109.     }
  110.     public function setIsTrue(bool $isTrue): self
  111.     {
  112.         $this->isTrue $isTrue;
  113.         return $this;
  114.     }
  115.     public function getCreatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->createdAt;
  118.     }
  119.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  120.     {
  121.         $this->createdAt $createdAt;
  122.         return $this;
  123.     }
  124.     public function getUpdatedAt(): ?\DateTimeInterface
  125.     {
  126.         return $this->updatedAt;
  127.     }
  128.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  129.     {
  130.         $this->updatedAt $updatedAt;
  131.         return $this;
  132.     }
  133.     public function getQuestion(): ?Question
  134.     {
  135.         return $this->question;
  136.     }
  137.     public function setQuestion(?Question $question): self
  138.     {
  139.         $this->question $question;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection|UserAnswer[]
  144.      */
  145.     public function getUserAnswer(): Collection
  146.     {
  147.         return $this->userAnswer;
  148.     }
  149.     public function addUserAnswer(UserAnswer $userAnswer): self
  150.     {
  151.         if (!$this->userAnswer->contains($userAnswer)) {
  152.             $this->userAnswer[] = $userAnswer;
  153.             $userAnswer->setAnswer($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeUserAnswer(UserAnswer $userAnswer): self
  158.     {
  159.         if ($this->userAnswer->contains($userAnswer)) {
  160.             $this->userAnswer->removeElement($userAnswer);
  161.             // set the owning side to null (unless already changed)
  162.             if ($userAnswer->getAnswer() === $this) {
  163.                 $userAnswer->setAnswer(null);
  164.             }
  165.         }
  166.         return $this;
  167.     }
  168.     /* ****************************** GETTERS & SETTERS ******************************  */
  169. }