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