src/Entity/Compra.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * @ORM\Table(name="compra", schema="perseo")
  9.  * @ORM\Entity(repositoryClass="App\Repository\CompraRepository")
  10.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  11.  */
  12. class Compra
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\Column(type="bigint", options={"unsigned":true})
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     protected $id;
  20.     /**
  21.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  22.      */
  23.     protected $deletedAt;
  24.     /**
  25.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  26.      * @Gedmo\Timestampable(on="update")
  27.      */
  28.     protected $updatedAt;
  29.     /**
  30.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  31.      * @Gedmo\Timestampable(on="create")
  32.      */
  33.     protected $createdAt;
  34.     /**
  35.      * @ORM\OneToOne(targetEntity="App\Entity\Operacion", mappedBy="compra")
  36.      */
  37.     protected $operacion;
  38.     /**
  39.      * @ORM\OneToMany(
  40.      *     targetEntity=\App\Entity\DetalleCompra::class,
  41.      *     mappedBy="compra",
  42.      *     orphanRemoval=true,
  43.      *     cascade={"persist","remove"}
  44.      * )
  45.      */
  46.     private $detalle;
  47.     public function __construct()
  48.     {
  49.         $this->detalle = new ArrayCollection();
  50.     }
  51.     public function __toString(): string
  52.     {
  53.         return $this->getOperacion()?->getIDperseo() ?? '---';
  54.     }
  55.     public function getId(): ?string
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getDeletedAt(): ?\DateTimeInterface
  60.     {
  61.         return $this->deletedAt;
  62.     }
  63.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  64.     {
  65.         $this->deletedAt $deletedAt;
  66.         return $this;
  67.     }
  68.     public function getUpdatedAt(): ?\DateTimeInterface
  69.     {
  70.         return $this->updatedAt;
  71.     }
  72.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  73.     {
  74.         $this->updatedAt $updatedAt;
  75.         return $this;
  76.     }
  77.     public function getCreatedAt(): ?\DateTimeInterface
  78.     {
  79.         return $this->createdAt;
  80.     }
  81.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  82.     {
  83.         $this->createdAt $createdAt;
  84.         return $this;
  85.     }
  86.     public function getOperacion(): ?Operacion
  87.     {
  88.         return $this->operacion;
  89.     }
  90.     public function setOperacion(?Operacion $operacion): self
  91.     {
  92.         // unset the owning side of the relation if necessary
  93.         if ($operacion === null && $this->operacion !== null) {
  94.             $this->operacion->setCompra(null);
  95.         }
  96.         // set the owning side of the relation if necessary
  97.         if ($operacion !== null && $operacion->getCompra() !== $this) {
  98.             $operacion->setCompra($this);
  99.         }
  100.         $this->operacion $operacion;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection|DetalleCompra[]
  105.      */
  106.     public function getDetalle(): Collection
  107.     {
  108.         return $this->detalle;
  109.     }
  110.     public function addDetalle(DetalleCompra $detalle): self
  111.     {
  112.         if (!$this->detalle->contains($detalle)) {
  113.             $this->detalle[] = $detalle;
  114.             $detalle->setCompra($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeDetalle(DetalleCompra $detalle): self
  119.     {
  120.         if ($this->detalle->removeElement($detalle)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($detalle->getCompra() === $this) {
  123.                 $detalle->setCompra(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128. }