src/Entity/Categories3.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\Categories3Repository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: Categories3Repository::class)]
  8. class Categories3
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\ManyToOne(targetEntity: Categories2::class, inversedBy: 'categories3')]
  15. private $category2;
  16. #[ORM\Column(type: 'string', length: 255)]
  17. private $name;
  18. #[ORM\Column(type: 'json', nullable: true)]
  19. private $tags = [];
  20. #[ORM\Column(type: 'datetime')]
  21. private $modified;
  22. #[ORM\Column(type: 'datetime')]
  23. private $created;
  24. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  25. private $slug;
  26. #[ORM\Column(type: 'array', nullable: true)]
  27. private $tagsArray;
  28. #[ORM\OneToMany(targetEntity: Products::class, mappedBy: 'category3')]
  29. private $products;
  30. #[ORM\Column(type: 'integer', nullable: true)]
  31. private $productCount;
  32. public function __construct()
  33. {
  34. $date = new \DateTime("now", new \DateTimeZone('Asia/Dubai'));
  35. $this->setModified($date);
  36. if ($this->getCreated() == null)
  37. {
  38. $this->setCreated($date);
  39. }
  40. $this->products = new ArrayCollection();
  41. }
  42. public function getId(): ?int
  43. {
  44. return $this->id;
  45. }
  46. public function getCategory2(): ?Categories2
  47. {
  48. return $this->category2;
  49. }
  50. public function setCategory2(?Categories2 $category2): self
  51. {
  52. $this->category2 = $category2;
  53. return $this;
  54. }
  55. public function getName(): ?string
  56. {
  57. return $this->name;
  58. }
  59. public function setName(string $name): self
  60. {
  61. $this->name = $name;
  62. return $this;
  63. }
  64. public function getTags(): ?array
  65. {
  66. return $this->tags;
  67. }
  68. public function setTags(array $tags): self
  69. {
  70. $this->tags = $tags;
  71. return $this;
  72. }
  73. public function getModified(): ?\DateTimeInterface
  74. {
  75. return $this->modified;
  76. }
  77. public function setModified(\DateTimeInterface $modified): self
  78. {
  79. $this->modified = $modified;
  80. return $this;
  81. }
  82. public function getCreated(): ?\DateTimeInterface
  83. {
  84. return $this->created;
  85. }
  86. public function setCreated(\DateTimeInterface $created): self
  87. {
  88. $this->created = $created;
  89. return $this;
  90. }
  91. public function getSlug(): ?string
  92. {
  93. return $this->slug;
  94. }
  95. public function setSlug(?string $slug): self
  96. {
  97. $this->slug = $slug;
  98. return $this;
  99. }
  100. public function getTagsArray(): ?array
  101. {
  102. return $this->tagsArray;
  103. }
  104. public function setTagsArray(array $tagsArray): self
  105. {
  106. $this->tagsArray = $tagsArray;
  107. return $this;
  108. }
  109. /**
  110. * @return Collection<int, Products>
  111. */
  112. public function getProducts(): Collection
  113. {
  114. return $this->products;
  115. }
  116. public function addProduct(Products $product): self
  117. {
  118. if (!$this->products->contains($product)) {
  119. $this->products[] = $product;
  120. $product->setCategory3($this);
  121. }
  122. return $this;
  123. }
  124. public function removeProduct(Products $product): self
  125. {
  126. if ($this->products->removeElement($product)) {
  127. // set the owning side to null (unless already changed)
  128. if ($product->getCategory3() === $this) {
  129. $product->setCategory3(null);
  130. }
  131. }
  132. return $this;
  133. }
  134. public function getProductCount(): ?int
  135. {
  136. return $this->productCount;
  137. }
  138. public function setProductCount(?int $productCount): self
  139. {
  140. $this->productCount = $productCount;
  141. return $this;
  142. }
  143. }