<?phpnamespace App\Entity;use App\Repository\ShopCategoryRepository;use DateTimeImmutable;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\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: ShopCategoryRepository::class)]class ShopCategory{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\OneToMany(targetEntity: Shop::class, mappedBy: 'shopCategory')] private Collection $shops; #[ORM\Column(length: 100)] #[Assert\NotBlank] #[Assert\Length(min: 2, max: 100)] private ?string $name = null; #[ORM\Column(length: 120, unique: true)] private ?string $slug = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Assert\Length(max: 1000)] private ?string $description = null; #[ORM\Column(length: 255, nullable: true)] private ?string $bannerImage = null; #[ORM\Column] private ?int $position = 0; #[ORM\Column] private ?bool $isActive = true; #[ORM\Column] private ?DateTimeImmutable $createdAt = null; #[ORM\Column(nullable: true)] private ?DateTimeImmutable $updatedAt = null; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] private ?self $parent = null; #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] private Collection $children; public function __construct() { $this->shops = new ArrayCollection(); $this->children = new ArrayCollection(); } public function getId(): ?int { return $this->id; } /** * @return Collection<int, Shop> */ public function getShops(): Collection { return $this->shops; } public function addShop(Shop $shop): static { if (!$this->shops->contains($shop)) { $this->shops->add($shop); $shop->setShopCategory($this); } return $this; } public function removeShop(Shop $shop): static { if ($this->shops->removeElement($shop)) { // set the owning side to null (unless already changed) if ($shop->getShopCategory() === $this) { $shop->setShopCategory(null); } } return $this; } /** * @return string|null */ public function getName(): ?string { return $this->name; } /** * @param string|null $name * @return ShopCategory */ public function setName(?string $name): ShopCategory { $this->name = $name; return $this; } /** * @return string|null */ public function getSlug(): ?string { return $this->slug; } /** * @param string|null $slug * @return ShopCategory */ public function setSlug(?string $slug): ShopCategory { $this->slug = $slug; return $this; } /** * @return string|null */ public function getDescription(): ?string { return $this->description; } /** * @param string|null $description * @return ShopCategory */ public function setDescription(?string $description): ShopCategory { $this->description = $description; return $this; } /** * @return string|null */ public function getBannerImage(): ?string { return $this->bannerImage; } /** * @param string|null $bannerImage * @return ShopCategory */ public function setBannerImage(?string $bannerImage): ShopCategory { $this->bannerImage = $bannerImage; return $this; } /** * @return int|null */ public function getPosition(): ?int { return $this->position; } /** * @param int|null $position * @return ShopCategory */ public function setPosition(?int $position): ShopCategory { $this->position = $position; return $this; } /** * @return bool|null */ public function getIsActive(): ?bool { return $this->isActive; } /** * @param bool|null $isActive * @return ShopCategory */ public function setIsActive(?bool $isActive): ShopCategory { $this->isActive = $isActive; return $this; } /** * @return DateTimeImmutable|null */ public function getCreatedAt(): ?DateTimeImmutable { return $this->createdAt; } /** * @param DateTimeImmutable|null $createdAt * @return ShopCategory */ public function setCreatedAt(?DateTimeImmutable $createdAt): ShopCategory { $this->createdAt = $createdAt; return $this; } /** * @return DateTimeImmutable|null */ public function getUpdatedAt(): ?DateTimeImmutable { return $this->updatedAt; } /** * @param DateTimeImmutable|null $updatedAt * @return ShopCategory */ public function setUpdatedAt(?DateTimeImmutable $updatedAt): ShopCategory { $this->updatedAt = $updatedAt; return $this; } /** * @return ShopCategory|null */ public function getParent(): ?ShopCategory { return $this->parent; } /** * @param ShopCategory|null $parent * @return ShopCategory */ public function setParent(?ShopCategory $parent): ShopCategory { $this->parent = $parent; return $this; } /** * @return Collection */ public function getChildren(): Collection { return $this->children; } /** * @param Collection $children * @return ShopCategory */ public function setChildren(Collection $children): ShopCategory { $this->children = $children; return $this; } public function __toString(): string { return $this->name ?? ''; }}