src/Entity/ValoracionesRelojes.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Uid\Uuid;
  9. /**
  10. * @ORM\Entity(repositoryClass="App\Repository\ValoracionesRelojesRepository")
  11. * @ORM\Table(name="valoraciones_relojes", schema="perseo",
  12. * indexes={
  13. * @ORM\Index(name="idx_vrelojes_type_deleted", columns={"type", "deleted_at", "valoracion_id"})
  14. * }
  15. * )
  16. * @ORM\InheritanceType("SINGLE_TABLE")
  17. * @ORM\DiscriminatorColumn(name="type", type="string")
  18. * @ORM\DiscriminatorMap({"stock":"App\Entity\ValoracionesRelojesStock","sinstock":"App\Entity\ValoracionesRelojesSinStock"})
  19. * @ORM\EntityListeners({"App\EntityListener\ValoracionesRelojes\CalcularIDPerseoListener"})
  20. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21. */
  22. class ValoracionesRelojes
  23. {
  24. /**
  25. * @ORM\Id
  26. * @ORM\Column(type="uuid", unique=true)
  27. * @ORM\GeneratedValue(strategy="CUSTOM")
  28. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  29. */
  30. protected $id;
  31. /**
  32. * @ORM\Column(
  33. * type="string",
  34. * unique=true,
  35. * nullable=true,
  36. * name="id_perseo",
  37. * options={"comment":"Identificador de perseo único generado aleatoriamente combinación letras y números"}
  38. * )
  39. */
  40. protected $IDperseo;
  41. /**
  42. * @ORM\Column(type="text", nullable=true, name="info_valoracion_compra", options={"default":NULL})
  43. */
  44. protected $infoValoracion;
  45. /**
  46. * @ORM\Column(type="boolean", nullable=true, name="is_precio_chrono24", options={"default":0})
  47. */
  48. protected $isPrecioChrono24;
  49. /**
  50. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  51. */
  52. protected $deletedAt;
  53. /**
  54. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  55. * @Gedmo\Timestampable(on="update")
  56. */
  57. protected $updatedAt;
  58. /**
  59. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  60. * @Gedmo\Timestampable(on="create")
  61. */
  62. protected $createdAt;
  63. /**
  64. * @ORM\OneToMany(targetEntity=\App\Entity\ValoracionesRelojes::class, mappedBy="clone")
  65. */
  66. protected $clones;
  67. /**
  68. * @ORM\ManyToOne(targetEntity="App\Entity\Valoracion", inversedBy="valoracionesRelojes", cascade={"persist"})
  69. * @ORM\JoinColumn(name="valoracion_id", referencedColumnName="id")
  70. */
  71. protected $valoracion;
  72. /**
  73. * @ORM\ManyToOne(targetEntity="App\Entity\Reloj", inversedBy="valoracionesRelojes", cascade={"persist"})
  74. * @ORM\JoinColumn(name="reloj_id", referencedColumnName="id")
  75. */
  76. protected $reloj;
  77. /**
  78. * @ORM\ManyToOne(targetEntity=\App\Entity\ValoracionesRelojes::class, inversedBy="clones")
  79. * @ORM\JoinColumn(name="clone_id", referencedColumnName="id")
  80. */
  81. protected $clone;
  82. public function __construct()
  83. {
  84. $this->clones = new ArrayCollection();
  85. }
  86. public function __clone(): void
  87. {
  88. $this->setCreatedAt(new DateTime('now'));
  89. $this->setUpdatedAt(new DateTime('now'));
  90. if($this instanceof ValoracionesRelojesSinStock) {
  91. $costes = $this->getCostes();
  92. foreach ($costes as $coste) {
  93. $costeClone = clone $coste;
  94. $this->addCoste($costeClone);
  95. }
  96. $referencias = $this->getReferencias();
  97. foreach ($referencias as $referencia) {
  98. $referenciaClone = clone $referencia;
  99. $this->addReferencia($referenciaClone);
  100. }
  101. }
  102. }
  103. public function __toString(): string
  104. {
  105. return $this->getId()??'---';
  106. }
  107. public function getId(): ?Uuid
  108. {
  109. return $this->id;
  110. }
  111. public function getDeletedAt(): ?\DateTimeInterface
  112. {
  113. return $this->deletedAt;
  114. }
  115. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  116. {
  117. $this->deletedAt = $deletedAt;
  118. return $this;
  119. }
  120. public function getUpdatedAt(): ?\DateTimeInterface
  121. {
  122. return $this->updatedAt;
  123. }
  124. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  125. {
  126. $this->updatedAt = $updatedAt;
  127. return $this;
  128. }
  129. public function getCreatedAt(): ?\DateTimeInterface
  130. {
  131. return $this->createdAt;
  132. }
  133. public function setCreatedAt(\DateTimeInterface $createdAt): self
  134. {
  135. $this->createdAt = $createdAt;
  136. return $this;
  137. }
  138. public function getValoracion(): ?Valoracion
  139. {
  140. return $this->valoracion;
  141. }
  142. public function setValoracion(?Valoracion $valoracion): self
  143. {
  144. $this->valoracion = $valoracion;
  145. return $this;
  146. }
  147. public function getReloj(): ?Reloj
  148. {
  149. return $this->reloj;
  150. }
  151. public function setReloj(?Reloj $reloj): self
  152. {
  153. $this->reloj = $reloj;
  154. return $this;
  155. }
  156. public function getInfoValoracion(): ?string
  157. {
  158. return $this->infoValoracion;
  159. }
  160. public function setInfoValoracion(?string $infoValoracion): self
  161. {
  162. $this->infoValoracion = $infoValoracion;
  163. return $this;
  164. }
  165. public function getIDperseo(): ?string
  166. {
  167. return $this->IDperseo;
  168. }
  169. public function setIDperseo(string $IDperseo): self
  170. {
  171. $this->IDperseo = $IDperseo;
  172. return $this;
  173. }
  174. /**
  175. * @return Collection|Valoracion[]
  176. */
  177. public function getClones(): Collection
  178. {
  179. return $this->clones;
  180. }
  181. public function addClone(Valoracion $clone): self
  182. {
  183. if (!$this->clones->contains($clone)) {
  184. $this->clones[] = $clone;
  185. $clone->setClone($this);
  186. }
  187. return $this;
  188. }
  189. public function removeClone(Valoracion $clone): self
  190. {
  191. if ($this->clones->removeElement($clone)) {
  192. // set the owning side to null (unless already changed)
  193. if ($clone->getClone() === $this) {
  194. $clone->setClone(null);
  195. }
  196. }
  197. return $this;
  198. }
  199. public function getClone(): ?self
  200. {
  201. return $this->clone;
  202. }
  203. public function setClone(?self $clone): self
  204. {
  205. $this->clone = $clone;
  206. return $this;
  207. }
  208. }