src/Entity/Categories.php line 11
<?phpnamespace App\Entity;use App\Repository\CategoriesRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CategoriesRepository::class)]class Categories{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column(type: 'integer')]private $id;#[ORM\ManyToOne(targetEntity: Categories::class, inversedBy: 'children')]private $parent;#[ORM\OneToMany(targetEntity: Categories::class, mappedBy: 'parent')]private $children;#[ORM\Column(type: 'string', length: 255)]private $category;#[ORM\Column(type: 'datetime')]private $modified;#[ORM\Column(type: 'datetime')]private $created;#[ORM\Column(type: 'integer', nullable: true)]private $rootId;#[ORM\Column(type: 'integer', nullable: true)]private $isRoot;#[ORM\OneToMany(targetEntity: Products::class, mappedBy: 'category')]private $products;#[ORM\Column(type: 'json', nullable: true)]private $childIds = [];#[ORM\OneToMany(targetEntity: SubCategories::class, mappedBy: 'category')]private $subCategories;public function __construct(){$date = new \DateTime("now", new \DateTimeZone('Asia/Dubai'));$this->setModified($date);if ($this->getCreated() == null){$this->setCreated($date);}$this->children = new ArrayCollection();$this->products = new ArrayCollection();$this->subCategories = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getParent(): ?self{return $this->parent;}public function setParent(?self $parent): self{$this->parent = $parent;return $this;}/*** @return Collection<int, self>*/public function getChildren(): Collection{return $this->children;}public function addChild(self $child): self{if (!$this->children->contains($child)) {$this->children[] = $child;$child->setParent($this);}return $this;}public function removeChild(self $child): self{if ($this->children->removeElement($child)) {// set the owning side to null (unless already changed)if ($child->getParent() === $this) {$child->setParent(null);}}return $this;}public function getCategory(): ?string{return $this->category;}public function setCategory(string $category): self{$this->category = $category;return $this;}public function getModified(): ?\DateTimeInterface{return $this->modified;}public function setModified(\DateTimeInterface $modified): self{$this->modified = $modified;return $this;}public function getCreated(): ?\DateTimeInterface{return $this->created;}public function setCreated(\DateTimeInterface $created): self{$this->created = $created;return $this;}public function getRootId(): ?int{return $this->rootId;}public function setRootId(?int $rootId): self{$this->rootId = $rootId;return $this;}public function getIsRoot(): ?int{return $this->isRoot;}public function setIsRoot(?int $isRoot): self{$this->isRoot = $isRoot;return $this;}/*** @return Collection|Products[]*/public function getProducts(): Collection{return $this->products;}public function addProduct(Products $product): self{if (!$this->products->contains($product)) {$this->products[] = $product;$product->setCategory($this);}return $this;}public function removeProduct(Products $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 getChildIds(): ?array{return $this->childIds;}public function setChildIds(?array $childIds): self{$this->childIds = $childIds;return $this;}/*** @return Collection|SubCategories[]*/public function getSubCategories(): Collection{return $this->subCategories;}public function addSubCategories(SubCategories $subCategories): self{if (!$this->subCategories->contains($subCategories)) {$this->subCategories[] = $subCategories;$subCategories->setCategory($this);}return $this;}public function removeSubCategories(SubCategories $subCategories): self{if ($this->subCategories->removeElement($subCategories)) {// set the owning side to null (unless already changed)if ($subCategories->getCategory() === $this) {$subCategories->setCategory(null);}}return $this;}}