<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass="App\Repository\ValoracionesRelojesRepository")
* @ORM\Table(name="valoraciones_relojes", schema="perseo",
* indexes={
* @ORM\Index(name="idx_vrelojes_type_deleted", columns={"type", "deleted_at", "valoracion_id"})
* }
* )
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"stock":"App\Entity\ValoracionesRelojesStock","sinstock":"App\Entity\ValoracionesRelojesSinStock"})
* @ORM\EntityListeners({"App\EntityListener\ValoracionesRelojes\CalcularIDPerseoListener"})
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
*/
class ValoracionesRelojes
{
/**
* @ORM\Id
* @ORM\Column(type="bigint")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(
* type="string",
* unique=true,
* nullable=true,
* name="id_perseo",
* options={"comment":"Identificador de perseo único generado aleatoriamente combinación letras y números"}
* )
*/
protected $IDperseo;
/**
* @ORM\Column(type="text", nullable=true, name="info_valoracion_compra", options={"default":NULL})
*/
protected $infoValoracion;
/**
* @ORM\Column(type="boolean", nullable=true, name="is_precio_chrono24", options={"default":0})
*/
protected $isPrecioChrono24;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\ValoracionesRelojes::class, mappedBy="clone")
*/
protected $clones;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Valoracion", inversedBy="valoracionesRelojes", cascade={"persist"})
* @ORM\JoinColumn(name="valoracion_id", referencedColumnName="id")
*/
protected $valoracion;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Reloj", inversedBy="valoracionesRelojes", cascade={"persist"})
* @ORM\JoinColumn(name="reloj_id", referencedColumnName="id")
*/
protected $reloj;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\ValoracionesRelojes::class, inversedBy="clones")
* @ORM\JoinColumn(name="clone_id", referencedColumnName="id")
*/
protected $clone;
public function __construct()
{
$this->clones = new ArrayCollection();
}
public function __clone(): void
{
$this->setCreatedAt(new DateTime('now'));
$this->setUpdatedAt(new DateTime('now'));
if($this instanceof ValoracionesRelojesSinStock) {
$costes = $this->getCostes();
foreach ($costes as $coste) {
$costeClone = clone $coste;
$this->addCoste($costeClone);
}
$referencias = $this->getReferencias();
foreach ($referencias as $referencia) {
$referenciaClone = clone $referencia;
$this->addReferencia($referenciaClone);
}
}
}
public function __toString(): string
{
return $this->getId()??'---';
}
public function getId(): ?int
{
return $this->id;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getValoracion(): ?Valoracion
{
return $this->valoracion;
}
public function setValoracion(?Valoracion $valoracion): self
{
$this->valoracion = $valoracion;
return $this;
}
public function getReloj(): ?Reloj
{
return $this->reloj;
}
public function setReloj(?Reloj $reloj): self
{
$this->reloj = $reloj;
return $this;
}
public function getInfoValoracion(): ?string
{
return $this->infoValoracion;
}
public function setInfoValoracion(?string $infoValoracion): self
{
$this->infoValoracion = $infoValoracion;
return $this;
}
public function getIDperseo(): ?string
{
return $this->IDperseo;
}
public function setIDperseo(string $IDperseo): self
{
$this->IDperseo = $IDperseo;
return $this;
}
/**
* @return Collection|Valoracion[]
*/
public function getClones(): Collection
{
return $this->clones;
}
public function addClone(Valoracion $clone): self
{
if (!$this->clones->contains($clone)) {
$this->clones[] = $clone;
$clone->setClone($this);
}
return $this;
}
public function removeClone(Valoracion $clone): self
{
if ($this->clones->removeElement($clone)) {
// set the owning side to null (unless already changed)
if ($clone->getClone() === $this) {
$clone->setClone(null);
}
}
return $this;
}
public function getClone(): ?self
{
return $this->clone;
}
public function setClone(?self $clone): self
{
$this->clone = $clone;
return $this;
}
}