<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Table(name="compra", schema="perseo")
* @ORM\Entity(repositoryClass="App\Repository\CompraRepository")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
*/
class Compra
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @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\OneToOne(targetEntity="App\Entity\Operacion", mappedBy="compra")
*/
protected $operacion;
/**
* @ORM\OneToMany(
* targetEntity=\App\Entity\DetalleCompra::class,
* mappedBy="compra",
* orphanRemoval=true,
* cascade={"persist","remove"}
* )
*/
private $detalle;
public function __construct()
{
$this->detalle = new ArrayCollection();
}
public function __toString(): string
{
return $this->getOperacion()?->getIDperseo() ?? '---';
}
public function getId(): ?string
{
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 getOperacion(): ?Operacion
{
return $this->operacion;
}
public function setOperacion(?Operacion $operacion): self
{
// unset the owning side of the relation if necessary
if ($operacion === null && $this->operacion !== null) {
$this->operacion->setCompra(null);
}
// set the owning side of the relation if necessary
if ($operacion !== null && $operacion->getCompra() !== $this) {
$operacion->setCompra($this);
}
$this->operacion = $operacion;
return $this;
}
/**
* @return Collection|DetalleCompra[]
*/
public function getDetalle(): Collection
{
return $this->detalle;
}
public function addDetalle(DetalleCompra $detalle): self
{
if (!$this->detalle->contains($detalle)) {
$this->detalle[] = $detalle;
$detalle->setCompra($this);
}
return $this;
}
public function removeDetalle(DetalleCompra $detalle): self
{
if ($this->detalle->removeElement($detalle)) {
// set the owning side to null (unless already changed)
if ($detalle->getCompra() === $this) {
$detalle->setCompra(null);
}
}
return $this;
}
}