<?phpnamespace App\Entity;use App\Entity\SubCategory;use Doctrine\ORM\Mapping as ORM;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\Collection;use Doctrine\Common\Collections\ArrayCollection;#[ORM\Entity(repositoryClass: CategoryRepository::class)]class Category{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(length: 255)] private ?string $slug = null; #[ORM\OneToMany(targetEntity: Page::class, mappedBy: 'categories')] private Collection $pages; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'subCategory')] private ?self $mainCategory = null; #[ORM\OneToMany(mappedBy: 'mainCategory', targetEntity: SubCategory::class)] private Collection $subCategories; public function __construct() { $this->pages = new ArrayCollection(); $this->subCategories = new ArrayCollection(); } public function __toString() { return $this->name; } 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; } /** * @return Collection<int, Page> */ public function getPages(): Collection { return $this->pages; } public function getMainCategory(): ?self { return $this->mainCategory; } public function setMainCategory(?self $mainCategory): static { $this->mainCategory = $mainCategory; return $this; } /** * @return Collection<int, SubCategory> */ public function getSubCategories(): Collection { return $this->subCategories; } /** * Get the value of slug */ public function getSlug() { return $this->slug; } /** * Set the value of slug * * @return self */ public function setSlug($slug) { $this->slug = $slug; return $this; }}