src/Entity/FaqSubject.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FaqSubjectRepository;
  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=FaqSubjectRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class FaqSubject 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 $subject;
  26. /**
  27. * @ORM\ManyToMany(targetEntity=FaqQuestion::class, inversedBy="faqSubjects", cascade={"persist", "remove"})
  28. */
  29. private $questions;
  30. public function __construct()
  31. {
  32. $this->questions = new ArrayCollection();
  33. }
  34. public function getId(): ?int
  35. {
  36. return $this->id;
  37. }
  38. public function getSubject(): ?string
  39. {
  40. return $this->subject;
  41. }
  42. public function setSubject(string $subject): self
  43. {
  44. $this->subject = $subject;
  45. return $this;
  46. }
  47. /**
  48. * @return Collection<int, FaqQuestion>
  49. */
  50. public function getQuestions(): Collection
  51. {
  52. return $this->questions;
  53. }
  54. public function addQuestion(FaqQuestion $question): self
  55. {
  56. if (!$this->questions->contains($question)) {
  57. $this->questions[] = $question;
  58. }
  59. return $this;
  60. }
  61. public function removeQuestion(FaqQuestion $question): self
  62. {
  63. $this->questions->removeElement($question);
  64. return $this;
  65. }
  66. }