src/Entity/FaqQuestion.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FaqQuestionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9. * @ORM\Entity(repositoryClass=FaqQuestionRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class FaqQuestion extends BaseEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. * @Serializer\Expose
  19. */
  20. private $id;
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. * @Serializer\Expose
  24. */
  25. private $question;
  26. /**
  27. * @ORM\ManyToMany(targetEntity=FaqSubject::class, mappedBy="questions")
  28. */
  29. private $faqSubjects;
  30. /**
  31. * @ORM\Column(type="text")
  32. * @Serializer\Expose
  33. */
  34. private $answer;
  35. /**
  36. * @ORM\ManyToMany(targetEntity=FaqAnswer::class, inversedBy="faqQuestions")
  37. */
  38. private $faqAnswers;
  39. public function __construct()
  40. {
  41. $this->faqSubjects = new ArrayCollection();
  42. }
  43. public function getId(): ?int
  44. {
  45. return $this->id;
  46. }
  47. public function getQuestion(): ?string
  48. {
  49. return $this->question;
  50. }
  51. public function setQuestion(string $question): self
  52. {
  53. $this->question = $question;
  54. return $this;
  55. }
  56. /**
  57. * @return Collection<int, FaqSubject>
  58. */
  59. public function getFaqSubjects(): Collection
  60. {
  61. return $this->faqSubjects;
  62. }
  63. public function addFaqSubject(FaqSubject $faqSubject): self
  64. {
  65. if (!$this->faqSubjects->contains($faqSubject)) {
  66. $this->faqSubjects[] = $faqSubject;
  67. $faqSubject->addQuestion($this);
  68. }
  69. return $this;
  70. }
  71. public function removeFaqSubject(FaqSubject $faqSubject): self
  72. {
  73. if ($this->faqSubjects->removeElement($faqSubject)) {
  74. $faqSubject->removeQuestion($this);
  75. }
  76. return $this;
  77. }
  78. public function getAnswer(): ?string
  79. {
  80. return $this->answer;
  81. }
  82. public function setAnswer(string $answer): self
  83. {
  84. $this->answer = $answer;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection<int, FaqAnswer>
  89. */
  90. public function getFaqAnswers(): Collection
  91. {
  92. return $this->faqAnswers;
  93. }
  94. public function addFaqAnswer(FaqAnswer $faqAnswer): self
  95. {
  96. if (!$this->faqAnswers->contains($faqAnswer)) {
  97. $this->faqAnswers[] = $faqAnswer;
  98. $faqAnswer->addFaqQuestion($this);
  99. }
  100. return $this;
  101. }
  102. public function removeFaqAnswer(FaqAnswer $faqAnswer): self
  103. {
  104. if ($this->faqAnswers->removeElement($faqAnswer)) {
  105. $faqAnswer->removeFaqQuestion($this);
  106. }
  107. return $this;
  108. }
  109. }