src/Entity/Provincia.php line 16

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. use Symfony\Component\Uid\Uuid;
  8. /**
  9. * @ORM\Entity(repositoryClass="App\Repository\ProvinciaRepository")
  10. * @ORM\Table(name="provincia", schema="perseo")
  11. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  12. */
  13. class Provincia
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\Column(type="uuid", unique=true)
  18. * @ORM\GeneratedValue(strategy="CUSTOM")
  19. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  20. */
  21. protected $id;
  22. /**
  23. * @ORM\Column(type="string", length=100, nullable=false)
  24. * @Gedmo\Translatable
  25. */
  26. protected $nombre;
  27. /**
  28. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  29. */
  30. protected $deletedAt;
  31. /**
  32. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  33. * @Gedmo\Timestampable(on="update")
  34. */
  35. protected $updatedAt;
  36. /**
  37. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  38. * @Gedmo\Timestampable(on="create")
  39. */
  40. protected $createdAt;
  41. /**
  42. * @ORM\OneToMany(targetEntity="App\Entity\Ciudad", mappedBy="provincia")
  43. */
  44. protected $ciudades;
  45. /**
  46. * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="provincia")
  47. */
  48. protected $user;
  49. /**
  50. * @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="provincia")
  51. */
  52. protected $clientes;
  53. /**
  54. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionProvincia")
  55. */
  56. protected $direccionFacturacionProvinciaVentas;
  57. /**
  58. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioProvincia")
  59. */
  60. protected $direccionEnvioProvinciaVentas;
  61. /**
  62. * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="provincias")
  63. * @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id", nullable=false)
  64. */
  65. protected $ccaa;
  66. public function __construct()
  67. {
  68. $this->ciudades = new ArrayCollection();
  69. $this->user = new ArrayCollection();
  70. $this->direccionFacturacionProvinciaVentas = new ArrayCollection();
  71. $this->direccionEnvioProvinciaVentas = new ArrayCollection();
  72. $this->clientes = new ArrayCollection();
  73. }
  74. public function __toString(): string
  75. {
  76. return $this->getNombre()??'---';
  77. }
  78. public function getId(): ?Uuid
  79. {
  80. return $this->id;
  81. }
  82. public function getNombre(): ?string
  83. {
  84. return $this->nombre;
  85. }
  86. public function setNombre(string $nombre): self
  87. {
  88. $this->nombre = $nombre;
  89. return $this;
  90. }
  91. public function getDeletedAt(): ?\DateTimeInterface
  92. {
  93. return $this->deletedAt;
  94. }
  95. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  96. {
  97. $this->deletedAt = $deletedAt;
  98. return $this;
  99. }
  100. public function getUpdatedAt(): ?\DateTimeInterface
  101. {
  102. return $this->updatedAt;
  103. }
  104. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  105. {
  106. $this->updatedAt = $updatedAt;
  107. return $this;
  108. }
  109. public function getCreatedAt(): ?\DateTimeInterface
  110. {
  111. return $this->createdAt;
  112. }
  113. public function setCreatedAt(\DateTimeInterface $createdAt): self
  114. {
  115. $this->createdAt = $createdAt;
  116. return $this;
  117. }
  118. /**
  119. * @return Collection|Ciudad[]
  120. */
  121. public function getCiudades(): Collection
  122. {
  123. return $this->ciudades;
  124. }
  125. public function addCiudade(Ciudad $ciudade): self
  126. {
  127. if (!$this->ciudades->contains($ciudade)) {
  128. $this->ciudades[] = $ciudade;
  129. $ciudade->setProvincia($this);
  130. }
  131. return $this;
  132. }
  133. public function removeCiudade(Ciudad $ciudade): self
  134. {
  135. if ($this->ciudades->removeElement($ciudade)) {
  136. // set the owning side to null (unless already changed)
  137. if ($ciudade->getProvincia() === $this) {
  138. $ciudade->setProvincia(null);
  139. }
  140. }
  141. return $this;
  142. }
  143. /**
  144. * @return Collection|User[]
  145. */
  146. public function getUser(): Collection
  147. {
  148. return $this->user;
  149. }
  150. public function addUser(User $user): self
  151. {
  152. if (!$this->user->contains($user)) {
  153. $this->user[] = $user;
  154. $user->setProvincia($this);
  155. }
  156. return $this;
  157. }
  158. public function removeUser(User $user): self
  159. {
  160. if ($this->user->removeElement($user)) {
  161. // set the owning side to null (unless already changed)
  162. if ($user->getProvincia() === $this) {
  163. $user->setProvincia(null);
  164. }
  165. }
  166. return $this;
  167. }
  168. /**
  169. * @return Collection|Venta[]
  170. */
  171. public function getDireccionFacturacionProvinciaVentas(): Collection
  172. {
  173. return $this->direccionFacturacionProvinciaVentas;
  174. }
  175. public function addDireccionFacturacionProvinciaVenta(Venta $direccionFacturacionProvinciaVenta): self
  176. {
  177. if (!$this->direccionFacturacionProvinciaVentas->contains($direccionFacturacionProvinciaVenta)) {
  178. $this->direccionFacturacionProvinciaVentas[] = $direccionFacturacionProvinciaVenta;
  179. $direccionFacturacionProvinciaVenta->setDireccionFacturacionProvincia($this);
  180. }
  181. return $this;
  182. }
  183. public function removeDireccionFacturacionProvinciaVenta(Venta $direccionFacturacionProvinciaVenta): self
  184. {
  185. if ($this->direccionFacturacionProvinciaVentas->removeElement($direccionFacturacionProvinciaVenta)) {
  186. // set the owning side to null (unless already changed)
  187. if ($direccionFacturacionProvinciaVenta->getDireccionFacturacionProvincia() === $this) {
  188. $direccionFacturacionProvinciaVenta->setDireccionFacturacionProvincia(null);
  189. }
  190. }
  191. return $this;
  192. }
  193. /**
  194. * @return Collection|Venta[]
  195. */
  196. public function getDireccionEnvioProvinciaVentas(): Collection
  197. {
  198. return $this->direccionEnvioProvinciaVentas;
  199. }
  200. public function addDireccionEnvioProvinciaVenta(Venta $direccionEnvioProvinciaVenta): self
  201. {
  202. if (!$this->direccionEnvioProvinciaVentas->contains($direccionEnvioProvinciaVenta)) {
  203. $this->direccionEnvioProvinciaVentas[] = $direccionEnvioProvinciaVenta;
  204. $direccionEnvioProvinciaVenta->setDireccionEnvioProvincia($this);
  205. }
  206. return $this;
  207. }
  208. public function removeDireccionEnvioProvinciaVenta(Venta $direccionEnvioProvinciaVenta): self
  209. {
  210. if ($this->direccionEnvioProvinciaVentas->removeElement($direccionEnvioProvinciaVenta)) {
  211. // set the owning side to null (unless already changed)
  212. if ($direccionEnvioProvinciaVenta->getDireccionEnvioProvincia() === $this) {
  213. $direccionEnvioProvinciaVenta->setDireccionEnvioProvincia(null);
  214. }
  215. }
  216. return $this;
  217. }
  218. public function getCcaa(): ?CCAA
  219. {
  220. return $this->ccaa;
  221. }
  222. public function setCcaa(?CCAA $ccaa): self
  223. {
  224. $this->ccaa = $ccaa;
  225. return $this;
  226. }
  227. /**
  228. * @return Collection|Cliente[]
  229. */
  230. public function getClientes(): Collection
  231. {
  232. return $this->clientes;
  233. }
  234. public function addCliente(Cliente $cliente): self
  235. {
  236. if (!$this->clientes->contains($cliente)) {
  237. $this->clientes[] = $cliente;
  238. $cliente->setProvincia($this);
  239. }
  240. return $this;
  241. }
  242. public function removeCliente(Cliente $cliente): self
  243. {
  244. if ($this->clientes->removeElement($cliente)) {
  245. // set the owning side to null (unless already changed)
  246. if ($cliente->getProvincia() === $this) {
  247. $cliente->setProvincia(null);
  248. }
  249. }
  250. return $this;
  251. }
  252. }