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",
  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.             $this->setRelojInventario(null);
  90.             $costes $this->getCostes();
  91.             foreach ($costes as $coste) {
  92.                 $costeClone = clone $coste;
  93.                 $this->addCoste($costeClone);
  94.             }
  95.             $referencias $this->getReferencias();
  96.             foreach ($referencias as $referencia) {
  97.                 $referenciaClone = clone $referencia;
  98.                 $this->addReferencia($referenciaClone);
  99.             }
  100.         }
  101.     }
  102.     public function __toString(): string
  103.     {
  104.         return $this->getId()??'---';
  105.     }
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getDeletedAt(): ?\DateTimeInterface
  111.     {
  112.         return $this->deletedAt;
  113.     }
  114.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  115.     {
  116.         $this->deletedAt $deletedAt;
  117.         return $this;
  118.     }
  119.     public function getUpdatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->updatedAt;
  122.     }
  123.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  124.     {
  125.         $this->updatedAt $updatedAt;
  126.         return $this;
  127.     }
  128.     public function getCreatedAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->createdAt;
  131.     }
  132.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  133.     {
  134.         $this->createdAt $createdAt;
  135.         return $this;
  136.     }
  137.     public function getValoracion(): ?Valoracion
  138.     {
  139.         return $this->valoracion;
  140.     }
  141.     public function setValoracion(?Valoracion $valoracion): self
  142.     {
  143.         $this->valoracion $valoracion;
  144.         return $this;
  145.     }
  146.     public function getReloj(): ?Reloj
  147.     {
  148.         return $this->reloj;
  149.     }
  150.     public function setReloj(?Reloj $reloj): self
  151.     {
  152.         $this->reloj $reloj;
  153.         return $this;
  154.     }
  155.     public function getInfoValoracion(): ?string
  156.     {
  157.         return $this->infoValoracion;
  158.     }
  159.     public function setInfoValoracion(?string $infoValoracion): self
  160.     {
  161.         $this->infoValoracion $infoValoracion;
  162.         return $this;
  163.     }
  164.     public function getIDperseo(): ?string
  165.     {
  166.         return $this->IDperseo;
  167.     }
  168.     public function setIDperseo(string $IDperseo): self
  169.     {
  170.         $this->IDperseo $IDperseo;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return Collection|Valoracion[]
  175.      */
  176.     public function getClones(): Collection
  177.     {
  178.         return $this->clones;
  179.     }
  180.     public function addClone(Valoracion $clone): self
  181.     {
  182.         if (!$this->clones->contains($clone)) {
  183.             $this->clones[] = $clone;
  184.             $clone->setClone($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removeClone(Valoracion $clone): self
  189.     {
  190.         if ($this->clones->removeElement($clone)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($clone->getClone() === $this) {
  193.                 $clone->setClone(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     public function getClone(): ?self
  199.     {
  200.         return $this->clone;
  201.     }
  202.     public function setClone(?self $clone): self
  203.     {
  204.         $this->clone $clone;
  205.         return $this;
  206.     }
  207.     public function getRelojMarca(): ?Marca
  208.     {
  209.         if ($this instanceof ValoracionesRelojesSinStock) {
  210.             return $this->getRelojMarca();
  211.         }
  212.         if ($this instanceof ValoracionesRelojesStock) {
  213.             return $this->getReloj()?->getMarca();
  214.         }
  215.         return null;
  216.     }
  217.     public function getRelojModelo1(): ?string
  218.     {
  219.         if ($this instanceof ValoracionesRelojesSinStock) {
  220.             return $this->getRelojModelo1();
  221.         }
  222.         if ($this instanceof ValoracionesRelojesStock) {
  223.             return $this->getReloj()?->getModelo1();
  224.         }
  225.         return null;
  226.     }
  227.     public function getRelojRef1(): ?string
  228.     {
  229.         if ($this instanceof ValoracionesRelojesSinStock) {
  230.             return $this->getRelojRef1();
  231.         }
  232.         if ($this instanceof ValoracionesRelojesStock) {
  233.             return $this->getReloj()?->getRef1();
  234.         }
  235.         return null;
  236.     }
  237.     public function getMargenDeseado(): ?float
  238.     {
  239.         if ($this instanceof ValoracionesRelojesSinStock) {
  240.             return $this->getMargenDeseado();
  241.         }
  242.         if ($this instanceof ValoracionesRelojesStock) {
  243.             return $this->getReloj()?->getMargenDeseado();
  244.         }
  245.         return null;
  246.     }
  247.     public function getPrecioPagar(): ?float
  248.     {
  249.         if ($this instanceof ValoracionesRelojesSinStock) {
  250.             return $this->getprecioPagar();
  251.         }
  252.         if ($this instanceof ValoracionesRelojesStock) {
  253.             return $this->getReloj()?->getPrecioPagar();
  254.         }
  255.         return null;
  256.     }
  257. }