src/Entity/FaqSubject.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\FaqSubjectRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassFaqSubjectRepository::class)]
  9. #[ApiResource]
  10. class FaqSubject
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $title null;
  18.     #[ORM\OneToMany(mappedBy'faqSubject'targetEntityFaq::class)]
  19.     private Collection $questions;
  20.     public function __construct()
  21.     {
  22.         $this->questions = new ArrayCollection();
  23.     }
  24.     public function __toString(): string
  25.     {
  26.        return $this->title;
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getTitle(): ?string
  33.     {
  34.         return $this->title;
  35.     }
  36.     public function setTitle(string $title): self
  37.     {
  38.         $this->title $title;
  39.         return $this;
  40.     }
  41.     /**
  42.      * @return Collection<int, Faq>
  43.      */
  44.     public function getQuestions(): Collection
  45.     {
  46.         return $this->questions;
  47.     }
  48.     public function addQuestion(Faq $question): self
  49.     {
  50.         if (!$this->questions->contains($question)) {
  51.             $this->questions->add($question);
  52.             $question->setFaqSubject($this);
  53.         }
  54.         return $this;
  55.     }
  56.     public function removeQuestion(Faq $question): self
  57.     {
  58.         if ($this->questions->removeElement($question)) {
  59.             // set the owning side to null (unless already changed)
  60.             if ($question->getFaqSubject() === $this) {
  61.                 $question->setFaqSubject(null);
  62.             }
  63.         }
  64.         return $this;
  65.     }
  66. }