src/Entity/Tag.php line 13
<?php
namespace App\Entity;
use App\Repository\TagRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: TagRepository::class)]
#[UniqueEntity(fields: "title", message: "Naslov taga već postoji")]
class Tag
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, unique: true, nullable: true)]
private $title;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $slug;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $titleTag;
#[ORM\Column(type: 'text', nullable: true)]
private $metaDescription;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $keywords;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $image;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isActive;
#[ORM\ManyToMany(targetEntity: Article::class, mappedBy: 'tag')]
private $articles;
public function __construct()
{
$this->articles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getTitleTag(): ?string
{
return $this->titleTag;
}
public function setTitleTag(?string $titleTag): self
{
$this->titleTag = $titleTag;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getKeywords(): ?string
{
return $this->keywords;
}
public function setKeywords(?string $keywords): self
{
$this->keywords = $keywords;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection<int, Article>
*/
public function getArticles(): Collection
{
return $this->articles;
}
public function addArticle(Article $article): self
{
if (!$this->articles->contains($article)) {
$this->articles[] = $article;
$article->addTag($this);
}
return $this;
}
public function removeArticle(Article $article): self
{
if ($this->articles->removeElement($article)) {
$article->removeTag($this);
}
return $this;
}
}