src/Entity/CCAA.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\CCAARepository")
  10. * @ORM\Table(name="ccaa", schema="perseo")
  11. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  12. */
  13. class CCAA
  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\Column(type="string", length=2, nullable=true, name="pais")
  43. */
  44. protected $pais;
  45. /**
  46. * @ORM\OneToMany(targetEntity="App\Entity\Provincia", mappedBy="ccaa")
  47. */
  48. protected $provincias;
  49. /**
  50. * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="ccaa")
  51. */
  52. protected $user;
  53. /**
  54. * @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="ccaa")
  55. */
  56. protected $clientes;
  57. /**
  58. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionCcaa")
  59. */
  60. protected $direccionFacturacionCcaaVentas;
  61. /**
  62. * @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioCcaa")
  63. */
  64. protected $direccionEnvioCcaaVentas;
  65. public function __construct()
  66. {
  67. $this->provincias = new ArrayCollection();
  68. $this->user = new ArrayCollection();
  69. $this->direccionFacturacionCcaaVentas = new ArrayCollection();
  70. $this->direccionEnvioCcaaVentas = new ArrayCollection();
  71. $this->clientes = new ArrayCollection();
  72. }
  73. public function __toString(): string
  74. {
  75. return $this->getNombre()??'---';
  76. }
  77. public function getId(): ?Uuid
  78. {
  79. return $this->id;
  80. }
  81. public function getNombre(): ?string
  82. {
  83. return $this->nombre;
  84. }
  85. public function setNombre(string $nombre): self
  86. {
  87. $this->nombre = $nombre;
  88. return $this;
  89. }
  90. public function getDeletedAt(): ?\DateTimeInterface
  91. {
  92. return $this->deletedAt;
  93. }
  94. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  95. {
  96. $this->deletedAt = $deletedAt;
  97. return $this;
  98. }
  99. public function getUpdatedAt(): ?\DateTimeInterface
  100. {
  101. return $this->updatedAt;
  102. }
  103. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  104. {
  105. $this->updatedAt = $updatedAt;
  106. return $this;
  107. }
  108. public function getCreatedAt(): ?\DateTimeInterface
  109. {
  110. return $this->createdAt;
  111. }
  112. public function setCreatedAt(\DateTimeInterface $createdAt): self
  113. {
  114. $this->createdAt = $createdAt;
  115. return $this;
  116. }
  117. /**
  118. * @return Collection|Provincia[]
  119. */
  120. public function getProvincias(): Collection
  121. {
  122. return $this->provincias;
  123. }
  124. public function addProvincia(Provincia $provincia): self
  125. {
  126. if (!$this->provincias->contains($provincia)) {
  127. $this->provincias[] = $provincia;
  128. $provincia->setCcaa($this);
  129. }
  130. return $this;
  131. }
  132. public function removeProvincia(Provincia $provincia): self
  133. {
  134. if ($this->provincias->removeElement($provincia)) {
  135. // set the owning side to null (unless already changed)
  136. if ($provincia->getCcaa() === $this) {
  137. $provincia->setCcaa(null);
  138. }
  139. }
  140. return $this;
  141. }
  142. /**
  143. * @return Collection|User[]
  144. */
  145. public function getUser(): Collection
  146. {
  147. return $this->user;
  148. }
  149. public function addUser(User $user): self
  150. {
  151. if (!$this->user->contains($user)) {
  152. $this->user[] = $user;
  153. $user->setCcaa($this);
  154. }
  155. return $this;
  156. }
  157. public function removeUser(User $user): self
  158. {
  159. if ($this->user->removeElement($user)) {
  160. // set the owning side to null (unless already changed)
  161. if ($user->getCcaa() === $this) {
  162. $user->setCcaa(null);
  163. }
  164. }
  165. return $this;
  166. }
  167. /**
  168. * @return Collection|Venta[]
  169. */
  170. public function getDireccionFacturacionCcaaVentas(): Collection
  171. {
  172. return $this->direccionFacturacionCcaaVentas;
  173. }
  174. public function addDireccionFacturacionCcaaVenta(Venta $direccionFacturacionCcaaVenta): self
  175. {
  176. if (!$this->direccionFacturacionCcaaVentas->contains($direccionFacturacionCcaaVenta)) {
  177. $this->direccionFacturacionCcaaVentas[] = $direccionFacturacionCcaaVenta;
  178. $direccionFacturacionCcaaVenta->setDireccionFacturacionCcaa($this);
  179. }
  180. return $this;
  181. }
  182. public function removeDireccionFacturacionCcaaVenta(Venta $direccionFacturacionCcaaVenta): self
  183. {
  184. if ($this->direccionFacturacionCcaaVentas->removeElement($direccionFacturacionCcaaVenta)) {
  185. // set the owning side to null (unless already changed)
  186. if ($direccionFacturacionCcaaVenta->getDireccionFacturacionCcaa() === $this) {
  187. $direccionFacturacionCcaaVenta->setDireccionFacturacionCcaa(null);
  188. }
  189. }
  190. return $this;
  191. }
  192. /**
  193. * @return Collection|Venta[]
  194. */
  195. public function getDireccionEnvioCcaaVentas(): Collection
  196. {
  197. return $this->direccionEnvioCcaaVentas;
  198. }
  199. public function addDireccionEnvioCcaaVenta(Venta $direccionEnvioCcaaVenta): self
  200. {
  201. if (!$this->direccionEnvioCcaaVentas->contains($direccionEnvioCcaaVenta)) {
  202. $this->direccionEnvioCcaaVentas[] = $direccionEnvioCcaaVenta;
  203. $direccionEnvioCcaaVenta->setDireccionEnvioCcaa($this);
  204. }
  205. return $this;
  206. }
  207. public function removeDireccionEnvioCcaaVenta(Venta $direccionEnvioCcaaVenta): self
  208. {
  209. if ($this->direccionEnvioCcaaVentas->removeElement($direccionEnvioCcaaVenta)) {
  210. // set the owning side to null (unless already changed)
  211. if ($direccionEnvioCcaaVenta->getDireccionEnvioCcaa() === $this) {
  212. $direccionEnvioCcaaVenta->setDireccionEnvioCcaa(null);
  213. }
  214. }
  215. return $this;
  216. }
  217. public function getPais(): ?string
  218. {
  219. return $this->pais;
  220. }
  221. public function setPais(?string $pais): self
  222. {
  223. $this->pais = $pais;
  224. return $this;
  225. }
  226. /**
  227. * @return Collection|Cliente[]
  228. */
  229. public function getClientes(): Collection
  230. {
  231. return $this->clientes;
  232. }
  233. public function addCliente(Cliente $cliente): self
  234. {
  235. if (!$this->clientes->contains($cliente)) {
  236. $this->clientes[] = $cliente;
  237. $cliente->setCcaa($this);
  238. }
  239. return $this;
  240. }
  241. public function removeCliente(Cliente $cliente): self
  242. {
  243. if ($this->clientes->removeElement($cliente)) {
  244. // set the owning side to null (unless already changed)
  245. if ($cliente->getCcaa() === $this) {
  246. $cliente->setCcaa(null);
  247. }
  248. }
  249. return $this;
  250. }
  251. }