src/Entity/ValoracionesRelojes.php line 24

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