src/Entity/Categories2.php line 11

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