<?phpnamespace App\Entity;use App\Repository\ProductCategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: ProductCategoryRepository::class)]class ProductCategory{ use IdentifiableTrait; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(length: 255)] private ?string $slug = null; #[ORM\OneToMany(mappedBy: 'category', targetEntity: Product::class)] private Collection $products; #[ORM\Column(nullable: true)] private ?int $position = null; public function __construct() { $this->products = new ArrayCollection(); } public function __toString(): string { return $this->getName(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): static { $this->slug = $slug; return $this; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): static { if (!$this->products->contains($product)) { $this->products->add($product); $product->setCategory($this); } return $this; } public function removeProduct(Product $product): static { 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 getPosition(): ?int { return $this->position; } public function setPosition(?int $position): static { $this->position = $position; return $this; }}