src/Entity/Website/Blog/Category.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\CategoryRepository;
  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(repositoryClassCategoryRepository::class)]
  12. class Category 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\ManyToOne(inversedBy'categories')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Website $website null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $name null;
  25.     #[ORM\ManyToMany(targetEntityArticle::class, inversedBy'categories')]
  26.     private Collection $articles;
  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 getWebsite(): ?Website
  37.     {
  38.         return $this->website;
  39.     }
  40.     public function setWebsite(?Website $shop): static
  41.     {
  42.         $this->website $shop;
  43.         return $this;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): static
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection<int, Article>
  56.      */
  57.     public function getArticles(): Collection
  58.     {
  59.         return $this->articles;
  60.     }
  61.     public function addArticle(Article $article): static
  62.     {
  63.         if (!$this->articles->contains($article)) {
  64.             $this->articles->add($article);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeArticle(Article $article): static
  69.     {
  70.         $this->articles->removeElement($article);
  71.         return $this;
  72.     }
  73. }