src/Entity/FaqCategory.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FaqCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. #[ORM\Entity(repositoryClassFaqCategoryRepository::class)]
  9. #[ORM\Table(name'`faq_categories`')]
  10. class FaqCategory
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length50)]
  18.     private ?string $title null;
  19.     #[ORM\OneToMany(mappedBy'faq_category'targetEntityFaq::class, cascade: ['ALL'])]
  20.     private Collection $faqs;
  21.     public function __construct()
  22.     {
  23.         $this->faqs = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getTitle(): ?string
  30.     {
  31.         return $this->title;
  32.     }
  33.     public function setTitle(string $title): self
  34.     {
  35.         $this->title $title;
  36.         return $this;
  37.     }
  38.     /**
  39.      * @return Collection<int, Faq>
  40.      */
  41.     public function getFaqs(): Collection
  42.     {
  43.         return $this->faqs;
  44.     }
  45.     public function addFaq(Faq $faq): self
  46.     {
  47.         if (!$this->faqs->contains($faq)) {
  48.             $this->faqs->add($faq);
  49.             $faq->setFaqCategory($this);
  50.         }
  51.         return $this;
  52.     }
  53.     public function removeFaq(Faq $faq): self
  54.     {
  55.         if ($this->faqs->removeElement($faq)) {
  56.             // set the owning side to null (unless already changed)
  57.             if ($faq->getFaqCategory() === $this) {
  58.                 $faq->setFaqCategory(null);
  59.             }
  60.         }
  61.         return $this;
  62.     }
  63. }