src/Entity/TipoCargoAbstract.php line 22

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