src/Entity/CRM/ProductCategory.php line 11

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\ProductCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProductCategoryRepository::class)]
  8. class ProductCategory
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $description null;
  18.     #[ORM\Column]
  19.     private int $priority 0;
  20.     #[ORM\Column]
  21.     private bool $isActive true;
  22.     #[ORM\ManyToMany(targetEntityProduct::class, mappedBy'category')]
  23.     private Collection $products;
  24.     public function __construct()
  25.     {
  26.         $this->products = new ArrayCollection();
  27.     }
  28.     public function __toString(): string
  29.     {
  30.         return $this->id.' '.$this->name;
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getName(): ?string
  37.     {
  38.         return $this->name;
  39.     }
  40.     public function setName(string $name): self
  41.     {
  42.         $this->name $name;
  43.         return $this;
  44.     }
  45.     public function getDescription(): ?string
  46.     {
  47.         return $this->description;
  48.     }
  49.     public function setDescription(?string $description): self
  50.     {
  51.         $this->description $description;
  52.         return $this;
  53.     }
  54.     public function isIsActive(): ?bool
  55.     {
  56.         return $this->isActive;
  57.     }
  58.     public function setIsActive(bool $isActive): self
  59.     {
  60.         $this->isActive $isActive;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, Product>
  65.      */
  66.     public function getProducts(): Collection
  67.     {
  68.         return $this->products;
  69.     }
  70.     public function addProduct(Product $product): self
  71.     {
  72.         if (!$this->products->contains($product)) {
  73.             $this->products->add($product);
  74.             $product->addCategory($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeProduct(Product $product): self
  79.     {
  80.         if ($this->products->removeElement($product)) {
  81.             $product->removeCategory($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function getPriority(): int
  86.     {
  87.         return $this->priority;
  88.     }
  89.     public function setPriority(int $priority): void
  90.     {
  91.         $this->priority $priority;
  92.     }
  93. }