src/Entity/Topic.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TopicRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. #[ORM\Entity(repositoryClassTopicRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Topic
  11. {
  12.     use \App\Traits\EntityDateTimeAbleTrait;
  13.     const STATUS_ACTIVE 1;
  14.     const STATUS_INACTIVE 0;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     /**
  20.      * @Gedmo\Translatable
  21.      */
  22.     #[ORM\Column(type'string'length255nullabletrue)]
  23.     private ?string $title null;
  24.     #[ORM\Column(type'integer'nullabletrue)]
  25.     private ?int $ordering null;
  26.     #[ORM\OneToMany(targetEntityFaq::class, mappedBy'topic'orphanRemovaltruecascade: ['persist'])]
  27.     private Collection $faqs;
  28.     public function __construct()
  29.     {
  30.         $this->faqs = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getTitle(): ?string
  37.     {
  38.         return $this->title;
  39.     }
  40.     public function setTitle(?string $title): self
  41.     {
  42.         $this->title $title;
  43.         return $this;
  44.     }
  45.     public function getOrdering(): ?int
  46.     {
  47.         return $this->ordering;
  48.     }
  49.     public function setOrdering(?int $ordering): self
  50.     {
  51.         $this->ordering $ordering;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, Faq>
  56.      */
  57.     public function getFaqs(): Collection
  58.     {
  59.         return $this->faqs;
  60.     }
  61.     public function addFaq(Faq $faq): self
  62.     {
  63.         if (!$this->faqs->contains($faq)) {
  64.             $this->faqs[] = $faq;
  65.             $faq->setTopic($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removeFaq(Faq $faq): self
  70.     {
  71.         if ($this->faqs->removeElement($faq)) {
  72.             // set the owning side to null (unless already changed)
  73.             if ($faq->getTopic() === $this) {
  74.                 $faq->setTopic(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79. }