src/Entity/ProductCategory.php line 16
<?phpnamespace App\Entity;use App\Repository\ProductCategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Uid\Uuid;#[ORM\Entity(repositoryClass: ProductCategoryRepository::class)]// #[UniqueEntity(['whitelabel', 'name'], message: 'Record with this name already exists.')]class ProductCategory{#[ORM\Id]#[ORM\Column(type: 'uuid', unique: true)]#[Groups(['BASE'])]private ?string $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $createDate = null;#[ORM\ManyToOne(inversedBy: 'productCategories')]private ?User $creatorUser = null;#[ORM\OneToMany(mappedBy: 'category', targetEntity: Product::class)]private Collection $products;#[ORM\ManyToOne(inversedBy: 'productCategories')]#[ORM\JoinColumn(nullable: false)]private ?Whitelabel $whitelabel = null;#[ORM\Column(options: ['default' => 1])]private ?int $position = null;public function __construct(){$this->id = Uuid::v4();$this->products = new ArrayCollection();}public function __toString(){return $this->getName();}public function getId(): ?string{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getCreateDate(): ?\DateTimeInterface{return $this->createDate;}public function setCreateDate(\DateTimeInterface $createDate): self{$this->createDate = $createDate;return $this;}public function getCreatorUser(): ?User{return $this->creatorUser;}public function setCreatorUser(?User $creatorUser): self{$this->creatorUser = $creatorUser;return $this;}/*** @return Collection<int, Product>*/public function getProducts(): Collection{return $this->products;}public function addProduct(Product $product): self{if (!$this->products->contains($product)) {$this->products->add($product);$product->setCategory($this);}return $this;}public function removeProduct(Product $product): self{if ($this->products->removeElement($product)) {// set the owning side to null (unless already changed)if ($product->getCategory() === $this) {$product->setCategory(null);}}return $this;}public function getWhitelabel(): ?Whitelabel{return $this->whitelabel;}public function setWhitelabel(?Whitelabel $whitelabel): self{$this->whitelabel = $whitelabel;return $this;}public function getPosition(): ?int{return $this->position;}public function setPosition(int $position): self{$this->position = $position;return $this;}}