src/Entity/TipoCargoAbstract.php line 23

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\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\TipoCargoAbstractRepository")
  10.  * @ORM\Table(name="tipo_cargo")
  11.  * @ORM\InheritanceType("SINGLE_TABLE")
  12.  * @ORM\DiscriminatorColumn(name="type", type="string")
  13.  * @ORM\DiscriminatorMap({
  14.  *     "servicio":"App\Entity\TipoCargoServicio",
  15.  *     "mejora":"App\Entity\TipoCargoMejora",
  16.  *     "venta":"App\Entity\TipoCargoVenta"
  17.  * })
  18.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  19.  */
  20. Abstract class TipoCargoAbstract
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\Column(type="bigint", options={"unsigned":true})
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     protected $id;
  28.     /**
  29.      * @ORM\Column(type="string", nullable=true)
  30.      */
  31.     protected $nombre;
  32.     /**
  33.      * @ORM\Column(type="string", nullable=true)
  34.      */
  35.     protected $descripcion;
  36.     /**
  37.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  38.      */
  39.     protected $deletedAt;
  40.     /**
  41.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  42.      * @Gedmo\Timestampable(on="update")
  43.      */
  44.     protected $updatedAt;
  45.     /**
  46.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  47.      * @Gedmo\Timestampable(on="create")
  48.      */
  49.     protected $createdAt;
  50.     /**
  51.      * @ORM\OneToMany(targetEntity="App\Entity\Gasto", mappedBy="tipoCargo")
  52.      */
  53.     protected $gastos;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\CosteVenta", mappedBy="tipoCargo")
  56.      */
  57.     protected $costesVenta;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity="App\Entity\Coste", mappedBy="tipoCargo")
  60.      */
  61.     protected $costes;
  62.     public function __construct()
  63.     {
  64.         $this->gastos = new ArrayCollection();
  65.         $this->costesVenta = new ArrayCollection();
  66.         $this->costes = new ArrayCollection();
  67.     }
  68.     public function __toString(): string
  69.     {
  70.         return $this->getNombre()??'---';
  71.     }
  72.     public function getId(): ?string
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getNombre(): ?string
  77.     {
  78.         return $this->nombre;
  79.     }
  80.     public function setNombre(?string $nombre): self
  81.     {
  82.         $this->nombre $nombre;
  83.         return $this;
  84.     }
  85.     public function getDescripcion(): ?string
  86.     {
  87.         return $this->descripcion;
  88.     }
  89.     public function setDescripcion(?string $descripcion): self
  90.     {
  91.         $this->descripcion $descripcion;
  92.         return $this;
  93.     }
  94.     public function getDeletedAt(): ?\DateTimeInterface
  95.     {
  96.         return $this->deletedAt;
  97.     }
  98.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  99.     {
  100.         $this->deletedAt $deletedAt;
  101.         return $this;
  102.     }
  103.     public function getUpdatedAt(): ?\DateTimeInterface
  104.     {
  105.         return $this->updatedAt;
  106.     }
  107.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  108.     {
  109.         $this->updatedAt $updatedAt;
  110.         return $this;
  111.     }
  112.     public function getCreatedAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->createdAt;
  115.     }
  116.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  117.     {
  118.         $this->createdAt $createdAt;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection|Gasto[]
  123.      */
  124.     public function getGastos(): Collection
  125.     {
  126.         return $this->gastos;
  127.     }
  128.     public function addGasto(Gasto $gasto): self
  129.     {
  130.         if (!$this->gastos->contains($gasto)) {
  131.             $this->gastos[] = $gasto;
  132.             $gasto->setTipoCargo($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeGasto(Gasto $gasto): self
  137.     {
  138.         if ($this->gastos->removeElement($gasto)) {
  139.             // set the owning side to null (unless already changed)
  140.             if ($gasto->getTipoCargo() === $this) {
  141.                 $gasto->setTipoCargo(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection|CosteVenta[]
  148.      */
  149.     public function getCostesVenta(): Collection
  150.     {
  151.         return $this->costesVenta;
  152.     }
  153.     public function addCostesVentum(CosteVenta $costesVentum): self
  154.     {
  155.         if (!$this->costesVenta->contains($costesVentum)) {
  156.             $this->costesVenta[] = $costesVentum;
  157.             $costesVentum->setTipoCargo($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeCostesVentum(CosteVenta $costesVentum): self
  162.     {
  163.         if ($this->costesVenta->removeElement($costesVentum)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($costesVentum->getTipoCargo() === $this) {
  166.                 $costesVentum->setTipoCargo(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return Collection|Coste[]
  173.      */
  174.     public function getCostes(): Collection
  175.     {
  176.         return $this->costes;
  177.     }
  178.     public function addCoste(Coste $coste): self
  179.     {
  180.         if (!$this->costes->contains($coste)) {
  181.             $this->costes[] = $coste;
  182.             $coste->setTipoCargo($this);
  183.         }
  184.         return $this;
  185.     }
  186.     public function removeCoste(Coste $coste): self
  187.     {
  188.         if ($this->costes->removeElement($coste)) {
  189.             // set the owning side to null (unless already changed)
  190.             if ($coste->getTipoCargo() === $this) {
  191.                 $coste->setTipoCargo(null);
  192.             }
  193.         }
  194.         return $this;
  195.     }
  196. }