src/Entity/ProductReviews.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductReviewsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: ProductReviewsRepository::class)]
  8. class ProductReviews
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\ManyToOne(targetEntity: Products::class, inversedBy: 'productReviews')]
  15. private $product;
  16. #[ORM\ManyToOne(targetEntity: ClinicUsers::class, inversedBy: 'productReviews')]
  17. private $clinicUser;
  18. #[ORM\Column(type: 'text')]
  19. private $review;
  20. #[ORM\Column(type: 'string', length: 255)]
  21. private $clinic;
  22. #[ORM\Column(type: 'integer', nullable: true)]
  23. private $likes;
  24. #[ORM\Column(type: 'integer')]
  25. private $rating;
  26. #[ORM\Column(type: 'datetime')]
  27. private $modified;
  28. #[ORM\Column(type: 'datetime')]
  29. private $created;
  30. #[ORM\OneToMany(targetEntity: ProductReviewLikes::class, mappedBy: 'productReview')]
  31. private $productReviewLikes;
  32. #[ORM\OneToMany(targetEntity: ProductReviewComments::class, mappedBy: 'review')]
  33. private $productReviewComments;
  34. #[ORM\Column(type: 'integer', nullable: true)]
  35. private $isApproved;
  36. public function __construct()
  37. {
  38. $date = new \DateTime("now", new \DateTimeZone('Asia/Dubai'));
  39. $this->setModified($date);
  40. if ($this->getCreated() == null)
  41. {
  42. $this->setCreated($date);
  43. }
  44. $this->productReviewLikes = new ArrayCollection();
  45. $this->productReviewComments = new ArrayCollection();
  46. }
  47. public function getId(): ?int
  48. {
  49. return $this->id;
  50. }
  51. public function getProduct(): ?Products
  52. {
  53. return $this->product;
  54. }
  55. public function setProduct(?Products $product): self
  56. {
  57. $this->product = $product;
  58. return $this;
  59. }
  60. public function getClinicUser(): ?ClinicUsers
  61. {
  62. return $this->clinicUser;
  63. }
  64. public function setClinicUser(?ClinicUsers $clinicUser): self
  65. {
  66. $this->clinicUser = $clinicUser;
  67. return $this;
  68. }
  69. public function getReview(): ?string
  70. {
  71. return $this->review;
  72. }
  73. public function setReview(string $review): self
  74. {
  75. $this->review = $review;
  76. return $this;
  77. }
  78. public function getClinic(): ?string
  79. {
  80. return $this->clinic;
  81. }
  82. public function setClinic(string $clinic): self
  83. {
  84. $this->clinic = $clinic;
  85. return $this;
  86. }
  87. public function getLikes(): ?int
  88. {
  89. return $this->likes;
  90. }
  91. public function setLikes(int $likes): self
  92. {
  93. $this->likes = $likes;
  94. return $this;
  95. }
  96. public function getRating(): ?int
  97. {
  98. return $this->rating;
  99. }
  100. public function setRating(int $rating): self
  101. {
  102. $this->rating = $rating;
  103. return $this;
  104. }
  105. public function getModified(): ?\DateTimeInterface
  106. {
  107. return $this->modified;
  108. }
  109. public function setModified(\DateTimeInterface $modified): self
  110. {
  111. $this->modified = $modified;
  112. return $this;
  113. }
  114. public function getCreated(): ?\DateTimeInterface
  115. {
  116. return $this->created;
  117. }
  118. public function setCreated(\DateTimeInterface $created): self
  119. {
  120. $this->created = $created;
  121. return $this;
  122. }
  123. /**
  124. * @return Collection<int, ProductReviewLikes>
  125. */
  126. public function getProductReviewLikes(): Collection
  127. {
  128. return $this->productReviewLikes;
  129. }
  130. public function addProductReviewLike(ProductReviewLikes $productReviewLike): self
  131. {
  132. if (!$this->productReviewLikes->contains($productReviewLike)) {
  133. $this->productReviewLikes[] = $productReviewLike;
  134. $productReviewLike->setProductReview($this);
  135. }
  136. return $this;
  137. }
  138. public function removeProductReviewLike(ProductReviewLikes $productReviewLike): self
  139. {
  140. if ($this->productReviewLikes->removeElement($productReviewLike)) {
  141. // set the owning side to null (unless already changed)
  142. if ($productReviewLike->getProductReview() === $this) {
  143. $productReviewLike->setProductReview(null);
  144. }
  145. }
  146. return $this;
  147. }
  148. /**
  149. * @return Collection<int, ProductReviewComments>
  150. */
  151. public function getProductReviewComments(): Collection
  152. {
  153. return $this->productReviewComments;
  154. }
  155. public function addProductReviewComment(ProductReviewComments $productReviewComment): self
  156. {
  157. if (!$this->productReviewComments->contains($productReviewComment)) {
  158. $this->productReviewComments[] = $productReviewComment;
  159. $productReviewComment->setReview($this);
  160. }
  161. return $this;
  162. }
  163. public function removeProductReviewComment(ProductReviewComments $productReviewComment): self
  164. {
  165. if ($this->productReviewComments->removeElement($productReviewComment)) {
  166. // set the owning side to null (unless already changed)
  167. if ($productReviewComment->getReview() === $this) {
  168. $productReviewComment->setReview(null);
  169. }
  170. }
  171. return $this;
  172. }
  173. public function getIsApproved(): ?int
  174. {
  175. return $this->isApproved;
  176. }
  177. public function setIsApproved(?int $isApproved): self
  178. {
  179. $this->isApproved = $isApproved;
  180. return $this;
  181. }
  182. }