src/Entity/Website/Blog/Tag.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website\Blog;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\SeoFieldsTrait;
  5. use App\Entity\Website\Website\Website;
  6. use App\Repository\Website\Blog\TagRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassTagRepository::class)]
  12. class Tag extends BaseEntity
  13. {
  14.     use SeoFieldsTrait;
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'guid'uniquetrue)]
  17.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  18.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  19.     private ?string $id;
  20.     #[ORM\Column(length255)]
  21.     private ?string $name null;
  22.     #[ORM\ManyToMany(targetEntityArticle::class, inversedBy'tags')]
  23.     private Collection $articles;
  24.     #[ORM\ManyToOne(inversedBy'tags')]
  25.     #[ORM\JoinColumn(nullablefalse)]
  26.     private ?Website $website null;
  27.     public function __construct()
  28.     {
  29.         parent::__construct();
  30.         $this->articles = new ArrayCollection();
  31.     }
  32.     public function getId(): ?string
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getName(): ?string
  37.     {
  38.         return $this->name;
  39.     }
  40.     public function setName(string $name): static
  41.     {
  42.         $this->name $name;
  43.         return $this;
  44.     }
  45.     /**
  46.      * @return Collection<int, Article>
  47.      */
  48.     public function getArticles(): Collection
  49.     {
  50.         return $this->articles;
  51.     }
  52.     public function addArticle(Article $article): static
  53.     {
  54.         if (!$this->articles->contains($article)) {
  55.             $this->articles->add($article);
  56.         }
  57.         return $this;
  58.     }
  59.     public function removeArticle(Article $article): static
  60.     {
  61.         $this->articles->removeElement($article);
  62.         return $this;
  63.     }
  64.     public function getWebsite(): ?Website
  65.     {
  66.         return $this->website;
  67.     }
  68.     public function setWebsite(?Website $shop): static
  69.     {
  70.         $this->website $shop;
  71.         return $this;
  72.     }
  73. }