src/Entity/Tag.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TagRepository;
  4. use App\Traits\CommonTrt;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=TagRepository::class)
  10.  */
  11. class Tag
  12. {
  13.     use CommonTrt;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $slug;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity=SectionTitle::class, mappedBy="tag")
  30.      */
  31.     private $sectionTitles;
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity=Documents::class, mappedBy="tag")
  34.      */
  35.     private $documents;
  36.     public function __construct()
  37.     {
  38.         $this->sectionTitles = new ArrayCollection();
  39.         $this->documents = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name = $name;
  52.         return $this;
  53.     }
  54.     public function getSlug(): ?string
  55.     {
  56.         return $this->slug;
  57.     }
  58.     public function setSlug(string $slug): self
  59.     {
  60.         $this->slug = $slug;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, SectionTitle>
  65.      */
  66.     public function getSectionTitles(): Collection
  67.     {
  68.         return $this->sectionTitles;
  69.     }
  70.     public function addSectionTitle(SectionTitle $sectionTitle): self
  71.     {
  72.         if (!$this->sectionTitles->contains($sectionTitle)) {
  73.             $this->sectionTitles[] = $sectionTitle;
  74.             $sectionTitle->addTag($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeSectionTitle(SectionTitle $sectionTitle): self
  79.     {
  80.         if ($this->sectionTitles->removeElement($sectionTitle)) {
  81.             $sectionTitle->removeTag($this);
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection|Documents[]
  87.      */
  88.     public function getDocuments(): Collection
  89.     {
  90.         return $this->documents;
  91.     }
  92.     public function addDocument(Documents $document): self
  93.     {
  94.         if (!$this->documents->contains($document)) {
  95.             $this->documents[] = $document;
  96.             $document->addTag($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeDocument(Documents $document): self
  101.     {
  102.         if ($this->documents->removeElement($document)) {
  103.             $document->removeTag($this);
  104.         }
  105.         return $this;
  106.     }
  107. }