src/Entity/Shop/Blog/Category.php line 14

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