src/Entity/Tag.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TagRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. #[ORM\Entity(repositoryClassTagRepository::class)]
  9. #[UniqueEntity(fields"title"message"Naslov taga već postoji")]
  10. class Tag
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[ORM\Column(type'string'length255uniquetruenullabletrue)]
  17.     private $title;
  18.     #[ORM\Column(type'string'length255nullabletrue)]
  19.     private $slug;
  20.     #[ORM\Column(type'string'length255nullabletrue)]
  21.     private $titleTag;
  22.     #[ORM\Column(type'text'nullabletrue)]
  23.     private $metaDescription;
  24.     #[ORM\Column(type'string'length255nullabletrue)]
  25.     private $keywords;
  26.     #[ORM\Column(type'string'length255nullabletrue)]
  27.     private $image;
  28.     #[ORM\Column(type'boolean'nullabletrue)]
  29.     private $isActive;
  30.     #[ORM\ManyToMany(targetEntityArticle::class, mappedBy'tag')]
  31.     private $articles;
  32.     public function __construct()
  33.     {
  34.         $this->articles = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getTitle(): ?string
  41.     {
  42.         return $this->title;
  43.     }
  44.     public function setTitle(?string $title): self
  45.     {
  46.         $this->title $title;
  47.         return $this;
  48.     }
  49.     public function getSlug(): ?string
  50.     {
  51.         return $this->slug;
  52.     }
  53.     public function setSlug(?string $slug): self
  54.     {
  55.         $this->slug $slug;
  56.         return $this;
  57.     }
  58.     public function getTitleTag(): ?string
  59.     {
  60.         return $this->titleTag;
  61.     }
  62.     public function setTitleTag(?string $titleTag): self
  63.     {
  64.         $this->titleTag $titleTag;
  65.         return $this;
  66.     }
  67.     public function getMetaDescription(): ?string
  68.     {
  69.         return $this->metaDescription;
  70.     }
  71.     public function setMetaDescription(?string $metaDescription): self
  72.     {
  73.         $this->metaDescription $metaDescription;
  74.         return $this;
  75.     }
  76.     public function getKeywords(): ?string
  77.     {
  78.         return $this->keywords;
  79.     }
  80.     public function setKeywords(?string $keywords): self
  81.     {
  82.         $this->keywords $keywords;
  83.         return $this;
  84.     }
  85.     public function getImage(): ?string
  86.     {
  87.         return $this->image;
  88.     }
  89.     public function setImage(?string $image): self
  90.     {
  91.         $this->image $image;
  92.         return $this;
  93.     }
  94.     public function getIsActive(): ?bool
  95.     {
  96.         return $this->isActive;
  97.     }
  98.     public function setIsActive(?bool $isActive): self
  99.     {
  100.         $this->isActive $isActive;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, Article>
  105.      */
  106.     public function getArticles(): Collection
  107.     {
  108.         return $this->articles;
  109.     }
  110.     public function addArticle(Article $article): self
  111.     {
  112.         if (!$this->articles->contains($article)) {
  113.             $this->articles[] = $article;
  114.             $article->addTag($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeArticle(Article $article): self
  119.     {
  120.         if ($this->articles->removeElement($article)) {
  121.             $article->removeTag($this);
  122.         }
  123.         return $this;
  124.     }
  125. }