<?php
namespace App\Entity\Website\Blog;
use App\Entity\BaseEntity;
use App\Entity\SeoFieldsTrait;
use App\Entity\Website\Website\Website;
use App\Repository\Website\Blog\TagRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: TagRepository::class)]
class Tag extends BaseEntity
{
use SeoFieldsTrait;
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: Article::class, inversedBy: 'tags')]
private Collection $articles;
#[ORM\ManyToOne(inversedBy: 'tags')]
#[ORM\JoinColumn(nullable: false)]
private ?Website $website = null;
public function __construct()
{
parent::__construct();
$this->articles = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Article>
*/
public function getArticles(): Collection
{
return $this->articles;
}
public function addArticle(Article $article): static
{
if (!$this->articles->contains($article)) {
$this->articles->add($article);
}
return $this;
}
public function removeArticle(Article $article): static
{
$this->articles->removeElement($article);
return $this;
}
public function getWebsite(): ?Website
{
return $this->website;
}
public function setWebsite(?Website $shop): static
{
$this->website = $shop;
return $this;
}
}