src/Entity/Ciudad.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator as PerseoAssert;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Uid\Uuid;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11. * @ORM\Entity(repositoryClass="App\Repository\CiudadRepository")
  12. * @ORM\Table(name="ciudad", schema="perseo")
  13. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  14. * @PerseoAssert\ContraintsValidarEntidadCp()
  15. */
  16. class Ciudad
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\Column(type="uuid", unique=true)
  21. * @ORM\GeneratedValue(strategy="CUSTOM")
  22. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  23. */
  24. protected $id;
  25. /**
  26. * @ORM\Column(type="string", length=100, nullable=false)
  27. * @Gedmo\Translatable
  28. */
  29. protected $nombre;
  30. /**
  31. * @ORM\Column(type="string", length=5, nullable=false)
  32. * @Assert\Length(5)
  33. */
  34. protected $cp;
  35. /**
  36. * @ORM\Column(type="datetime", nullable=true)
  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\Column(type="string", length=2, nullable=true, name="pais")
  51. */
  52. protected $pais;
  53. /**
  54. * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="ciudad")
  55. */
  56. protected $user;
  57. /**
  58. * @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="ciudad")
  59. */
  60. protected $clientes;
  61. /**
  62. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionCiudad")
  63. */
  64. protected $direccionFacturacionCiudadVentas;
  65. /**
  66. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioCiudad")
  67. */
  68. protected $direccionEnvioCiudadVentas;
  69. /**
  70. * @ORM\OneToMany(targetEntity="App\Entity\Banco", mappedBy="ciudad")
  71. */
  72. protected $bancos;
  73. /**
  74. * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="ciudades")
  75. * @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
  76. */
  77. protected $provincia;
  78. public function __construct()
  79. {
  80. $this->user = new ArrayCollection();
  81. $this->direccionFacturacionCiudadVentas = new ArrayCollection();
  82. $this->direccionEnvioCiudadVentas = new ArrayCollection();
  83. $this->bancos = new ArrayCollection();
  84. $this->clientes = new ArrayCollection();
  85. }
  86. public function getId(): ?Uuid
  87. {
  88. return $this->id;
  89. }
  90. public function getNombre(): ?string
  91. {
  92. return $this->nombre;
  93. }
  94. public function setNombre(string $nombre): self
  95. {
  96. $this->nombre = $nombre;
  97. return $this;
  98. }
  99. public function getCp(): ?string
  100. {
  101. return $this->cp;
  102. }
  103. public function setCp(string $cp): self
  104. {
  105. $this->cp = $cp;
  106. return $this;
  107. }
  108. public function getDeletedAt(): ?\DateTimeInterface
  109. {
  110. return $this->deletedAt;
  111. }
  112. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  113. {
  114. $this->deletedAt = $deletedAt;
  115. return $this;
  116. }
  117. public function getUpdatedAt(): ?\DateTimeInterface
  118. {
  119. return $this->updatedAt;
  120. }
  121. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  122. {
  123. $this->updatedAt = $updatedAt;
  124. return $this;
  125. }
  126. public function getCreatedAt(): ?\DateTimeInterface
  127. {
  128. return $this->createdAt;
  129. }
  130. public function setCreatedAt(\DateTimeInterface $createdAt): self
  131. {
  132. $this->createdAt = $createdAt;
  133. return $this;
  134. }
  135. /**
  136. * @return Collection|User[]
  137. */
  138. public function getUser(): Collection
  139. {
  140. return $this->user;
  141. }
  142. public function addUser(User $user): self
  143. {
  144. if (!$this->user->contains($user)) {
  145. $this->user[] = $user;
  146. $user->setCiudad($this);
  147. }
  148. return $this;
  149. }
  150. public function removeUser(User $user): self
  151. {
  152. if ($this->user->removeElement($user)) {
  153. // set the owning side to null (unless already changed)
  154. if ($user->getCiudad() === $this) {
  155. $user->setCiudad(null);
  156. }
  157. }
  158. return $this;
  159. }
  160. /**
  161. * @return Collection|Venta[]
  162. */
  163. public function getDireccionFacturacionCiudadVentas(): Collection
  164. {
  165. return $this->direccionFacturacionCiudadVentas;
  166. }
  167. public function addDireccionFacturacionCiudadVenta(Venta $direccionFacturacionCiudadVenta): self
  168. {
  169. if (!$this->direccionFacturacionCiudadVentas->contains($direccionFacturacionCiudadVenta)) {
  170. $this->direccionFacturacionCiudadVentas[] = $direccionFacturacionCiudadVenta;
  171. $direccionFacturacionCiudadVenta->setDireccionFacturacionCiudad($this);
  172. }
  173. return $this;
  174. }
  175. public function removeDireccionFacturacionCiudadVenta(Venta $direccionFacturacionCiudadVenta): self
  176. {
  177. if ($this->direccionFacturacionCiudadVentas->removeElement($direccionFacturacionCiudadVenta)) {
  178. // set the owning side to null (unless already changed)
  179. if ($direccionFacturacionCiudadVenta->getDireccionFacturacionCiudad() === $this) {
  180. $direccionFacturacionCiudadVenta->setDireccionFacturacionCiudad(null);
  181. }
  182. }
  183. return $this;
  184. }
  185. /**
  186. * @return Collection|Venta[]
  187. */
  188. public function getDireccionEnvioCiudadVentas(): Collection
  189. {
  190. return $this->direccionEnvioCiudadVentas;
  191. }
  192. public function addDireccionEnvioCiudadVenta(Venta $direccionEnvioCiudadVenta): self
  193. {
  194. if (!$this->direccionEnvioCiudadVentas->contains($direccionEnvioCiudadVenta)) {
  195. $this->direccionEnvioCiudadVentas[] = $direccionEnvioCiudadVenta;
  196. $direccionEnvioCiudadVenta->setDireccionEnvioCiudad($this);
  197. }
  198. return $this;
  199. }
  200. public function removeDireccionEnvioCiudadVenta(Venta $direccionEnvioCiudadVenta): self
  201. {
  202. if ($this->direccionEnvioCiudadVentas->removeElement($direccionEnvioCiudadVenta)) {
  203. // set the owning side to null (unless already changed)
  204. if ($direccionEnvioCiudadVenta->getDireccionEnvioCiudad() === $this) {
  205. $direccionEnvioCiudadVenta->setDireccionEnvioCiudad(null);
  206. }
  207. }
  208. return $this;
  209. }
  210. public function getProvincia(): ?Provincia
  211. {
  212. return $this->provincia;
  213. }
  214. public function setProvincia(?Provincia $provincia): self
  215. {
  216. $this->provincia = $provincia;
  217. return $this;
  218. }
  219. public function getPais(): ?string
  220. {
  221. return $this->pais;
  222. }
  223. public function setPais(?string $pais): self
  224. {
  225. $this->pais = $pais;
  226. return $this;
  227. }
  228. /**
  229. * @return Collection|Banco[]
  230. */
  231. public function getBancos(): Collection
  232. {
  233. return $this->bancos;
  234. }
  235. public function addBanco(Banco $banco): self
  236. {
  237. if (!$this->bancos->contains($banco)) {
  238. $this->bancos[] = $banco;
  239. $banco->setCiudad($this);
  240. }
  241. return $this;
  242. }
  243. public function removeBanco(Banco $banco): self
  244. {
  245. if ($this->bancos->removeElement($banco)) {
  246. // set the owning side to null (unless already changed)
  247. if ($banco->getCiudad() === $this) {
  248. $banco->setCiudad(null);
  249. }
  250. }
  251. return $this;
  252. }
  253. /**
  254. * @return Collection|Cliente[]
  255. */
  256. public function getClientes(): Collection
  257. {
  258. return $this->clientes;
  259. }
  260. public function addCliente(Cliente $cliente): self
  261. {
  262. if (!$this->clientes->contains($cliente)) {
  263. $this->clientes[] = $cliente;
  264. $cliente->setCiudad($this);
  265. }
  266. return $this;
  267. }
  268. public function removeCliente(Cliente $cliente): self
  269. {
  270. if ($this->clientes->removeElement($cliente)) {
  271. // set the owning side to null (unless already changed)
  272. if ($cliente->getCiudad() === $this) {
  273. $cliente->setCiudad(null);
  274. }
  275. }
  276. return $this;
  277. }
  278. }