<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=CategoryRepository::class) */class Category{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $name; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $slug; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $color; /** * @ORM\OneToMany(targetEntity=SubCategory::class, mappedBy="category") */ private $subCategories; public function __construct() { $this->subCategories = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(?string $name): self { $this->name = $name; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(?string $slug): self { $this->slug = $slug; return $this; } public function getColor(): ?string { return $this->color; } public function setColor(?string $color): self { $this->color = $color; return $this; } /** * @return Collection<int, SubCategory> */ public function getSubCategories(): Collection { return $this->subCategories; } public function addSubCategory(SubCategory $subCategory): self { if (!$this->subCategories->contains($subCategory)) { $this->subCategories[] = $subCategory; $subCategory->setCategory($this); } return $this; } public function removeSubCategory(SubCategory $subCategory): self { if ($this->subCategories->removeElement($subCategory)) { // set the owning side to null (unless already changed) if ($subCategory->getCategory() === $this) { $subCategory->setCategory(null); } } return $this; }}