src/Entity/Cliente.php line 25

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\Intl\Countries;
  11. use Symfony\Component\Uid\Uuid;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15. * @ORM\Table(name="cliente", schema="perseo")
  16. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  17. * @ORM\Entity(repositoryClass="App\Repository\ClienteRepository")
  18. * @Vich\Uploadable
  19. * @UniqueEntity("identificacion")
  20. * @PerseoAssert\ContraintsValidarEntidadCp()
  21. */
  22. class Cliente
  23. {
  24. /**
  25. * @ORM\Id
  26. * @ORM\Column(type="uuid", unique=true)
  27. * @ORM\GeneratedValue(strategy="CUSTOM")
  28. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  29. */
  30. public $id;
  31. /**
  32. * @ORM\Column(type="string", nullable=true, name="razon_social")
  33. */
  34. protected $razonSocial;
  35. /**
  36. * @ORM\Column(type="string", nullable=true, name="alias")
  37. */
  38. protected $alias;
  39. /**
  40. * @ORM\Column(type="string", nullable=true, options={"comment":"DNI, Pasaporte, Licencia de Condución"})
  41. */
  42. protected $identificacionTipo;
  43. /**
  44. * @ORM\Column(type="string", nullable=true)
  45. */
  46. protected $identificacion;
  47. /**
  48. * @ORM\Column(type="string", nullable=true)
  49. */
  50. protected $direccion;
  51. /**
  52. * @ORM\Column(type="string", length=12, nullable=true)
  53. * @Assert\Length(min = 5, max = 12)
  54. */
  55. protected $cp;
  56. /**
  57. * @ORM\Column(type="string", nullable=true)
  58. */
  59. protected $region;
  60. /**
  61. * @ORM\Column(type="string", nullable=true)
  62. */
  63. protected $ciudad;
  64. /**
  65. * @ORM\Column(type="string", nullable=true)
  66. */
  67. protected $telefono;
  68. /**
  69. * @ORM\Column(type="string", nullable=true)
  70. */
  71. protected $email;
  72. /**
  73. * @ORM\Column(type="string", nullable=true)
  74. */
  75. protected $identificacionFrontal;
  76. /**
  77. * @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionFrontal")
  78. * @Assert\File(
  79. * maxSize = "15M",
  80. * mimeTypes = {
  81. * "image/jpeg",
  82. * "image/png",
  83. * "image/gif",
  84. * "image/webp",
  85. * "application/pdf"
  86. * },
  87. * mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
  88. * )
  89. * @var File
  90. */
  91. protected $identificacionFrontalFile;
  92. /**
  93. * @ORM\Column(type="string", nullable=true)
  94. */
  95. protected $identificacionTrasera;
  96. /**
  97. * @Vich\UploadableField(mapping="cliente", fileNameProperty="identificacionTrasera")
  98. * @Assert\File(
  99. * maxSize = "15M",
  100. * mimeTypes = {
  101. * "image/jpeg",
  102. * "image/png",
  103. * "image/gif",
  104. * "image/webp",
  105. * "application/pdf"
  106. * },
  107. * mimeTypesMessage = "Solo se permiten imágenes (JPEG, PNG, GIF, WEBP) o archivos PDF."
  108. * )
  109. * @var File
  110. */
  111. protected $identificacionTraseraFile;
  112. /**
  113. * @ORM\Column(type="string", length=2, nullable=true)
  114. */
  115. protected $idioma;
  116. /**
  117. * @ORM\Column(type="string", nullable=true, name="entidad_bancaria")
  118. */
  119. protected $entidadBancaria;
  120. /**
  121. * @ORM\Column(type="string", nullable=true)
  122. */
  123. protected $iban;
  124. /**
  125. * @ORM\Column(type="text", nullable=true)
  126. */
  127. protected $observaciones;
  128. /**
  129. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  130. */
  131. protected $deletedAt;
  132. /**
  133. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  134. * @Gedmo\Timestampable(on="update")
  135. */
  136. protected $updatedAt;
  137. /**
  138. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  139. * @Gedmo\Timestampable(on="create")
  140. */
  141. protected $createdAt;
  142. /**
  143. * @ORM\Column(type="string", length=2, nullable=true, name="pais")
  144. */
  145. protected $pais;
  146. /**
  147. * @ORM\OneToOne(targetEntity="App\Entity\User", mappedBy="cliente")
  148. */
  149. protected $user;
  150. /**
  151. * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="cliente")
  152. */
  153. protected $valoraciones;
  154. /**
  155. * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="cliente")
  156. */
  157. private $actividades;
  158. /**
  159. * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="cliente")
  160. */
  161. protected $operaciones;
  162. /*
  163. * @ORM\ManyToOne(targetEntity="App\Entity\Ciudad", inversedBy="clientes")
  164. * @ORM\JoinColumn(name="ciudad_id", referencedColumnName="id")
  165. */
  166. //protected $ciudad;
  167. /**
  168. * @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="clientes")
  169. * @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id")
  170. */
  171. protected $ccaa;
  172. /**
  173. * @ORM\ManyToOne(targetEntity="App\Entity\Provincia", inversedBy="clientes")
  174. * @ORM\JoinColumn(name="provincia_id", referencedColumnName="id")
  175. */
  176. protected $provincia;
  177. public function __construct()
  178. {
  179. $this->valoraciones = new ArrayCollection();
  180. $this->operaciones = new ArrayCollection();
  181. $this->actividades = new ArrayCollection();
  182. }
  183. public function __toString(): string
  184. {
  185. return $this->getRazonSocial() ? $this->getRazonSocial() : ($this->getUser() ? $this->getUser()?->getNombreCompleto() : '---');
  186. }
  187. public function getId(): ?Uuid
  188. {
  189. return $this->id;
  190. }
  191. public function getRazonSocial(): ?string
  192. {
  193. return $this->razonSocial;
  194. }
  195. public function setRazonSocial(?string $razonSocial): self
  196. {
  197. $this->razonSocial = $razonSocial;
  198. return $this;
  199. }
  200. public function getAlias(): ?string
  201. {
  202. return $this->alias;
  203. }
  204. public function setAlias(?string $alias): self
  205. {
  206. $this->alias = $alias;
  207. return $this;
  208. }
  209. public function getIdentificacionTipo(): ?string
  210. {
  211. return $this->identificacionTipo;
  212. }
  213. public function setIdentificacionTipo(?string $identificacionTipo): self
  214. {
  215. $this->identificacionTipo = $identificacionTipo;
  216. return $this;
  217. }
  218. public function getIdentificacion(): ?string
  219. {
  220. return $this->identificacion;
  221. }
  222. public function setIdentificacion(?string $identificacion): self
  223. {
  224. $this->identificacion = $identificacion;
  225. return $this;
  226. }
  227. public function getIdentificacionFrontal(): ?string
  228. {
  229. return $this->identificacionFrontal;
  230. }
  231. public function setIdentificacionFrontal(?string $identificacionFrontal): self
  232. {
  233. $this->identificacionFrontal = $identificacionFrontal;
  234. return $this;
  235. }
  236. public function getIdentificacionFrontalFile(): ?File
  237. {
  238. return $this->identificacionFrontalFile;
  239. }
  240. public function setIdentificacionFrontalFile(?File $identificacionFrontalFile): self
  241. {
  242. $this->identificacionFrontalFile = $identificacionFrontalFile;
  243. if ($identificacionFrontalFile) {
  244. // if 'updatedAt' is not defined in your entity, use another property
  245. $this->setUpdatedAt(new \DateTime('now'));
  246. }
  247. return $this;
  248. }
  249. public function getIdentificacionTrasera(): ?string
  250. {
  251. return $this->identificacionTrasera;
  252. }
  253. public function setIdentificacionTrasera(?string $identificacionTrasera): self
  254. {
  255. $this->identificacionTrasera = $identificacionTrasera;
  256. return $this;
  257. }
  258. public function getIdentificacionTraseraFile(): ?File
  259. {
  260. return $this->identificacionTraseraFile;
  261. }
  262. public function setIdentificacionTraseraFile(?File $identificacionTraseraFile): self
  263. {
  264. $this->identificacionTraseraFile = $identificacionTraseraFile;
  265. if ($identificacionTraseraFile) {
  266. // if 'updatedAt' is not defined in your entity, use another property
  267. $this->setUpdatedAt(new \DateTime('now'));
  268. }
  269. return $this;
  270. }
  271. public function getIdioma(): ?string
  272. {
  273. return $this->idioma;
  274. }
  275. public function setIdioma(?string $idioma): self
  276. {
  277. $this->idioma = $idioma;
  278. return $this;
  279. }
  280. public function getEntidadBancaria(): ?string
  281. {
  282. return $this->entidadBancaria;
  283. }
  284. public function setEntidadBancaria(?string $entidadBancaria): self
  285. {
  286. $this->entidadBancaria = $entidadBancaria;
  287. return $this;
  288. }
  289. public function getIban(): ?string
  290. {
  291. return $this->iban;
  292. }
  293. public function setIban(?string $iban): self
  294. {
  295. $this->iban = $iban;
  296. return $this;
  297. }
  298. public function getObservaciones(): ?string
  299. {
  300. return $this->observaciones;
  301. }
  302. public function setObservaciones(?string $observaciones): self
  303. {
  304. $this->observaciones = $observaciones;
  305. return $this;
  306. }
  307. public function getDeletedAt(): ?\DateTimeInterface
  308. {
  309. return $this->deletedAt;
  310. }
  311. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  312. {
  313. $this->deletedAt = $deletedAt;
  314. return $this;
  315. }
  316. public function getUpdatedAt(): ?\DateTimeInterface
  317. {
  318. return $this->updatedAt;
  319. }
  320. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  321. {
  322. $this->updatedAt = $updatedAt;
  323. return $this;
  324. }
  325. public function getCreatedAt(): ?\DateTimeInterface
  326. {
  327. return $this->createdAt;
  328. }
  329. public function setCreatedAt(\DateTimeInterface $createdAt): self
  330. {
  331. $this->createdAt = $createdAt;
  332. return $this;
  333. }
  334. public function getUser(): ?User
  335. {
  336. return $this->user;
  337. }
  338. public function setUser(?User $user): self
  339. {
  340. // unset the owning side of the relation if necessary
  341. if ($user === null && $this->user !== null) {
  342. $this->user->setCliente(null);
  343. }
  344. // set the owning side of the relation if necessary
  345. if ($user !== null && $user->getCliente() !== $this) {
  346. $user->setCliente($this);
  347. }
  348. $this->user = $user;
  349. return $this;
  350. }
  351. /**
  352. * @return Collection|Valoracion[]
  353. */
  354. public function getValoraciones(): Collection
  355. {
  356. return $this->valoraciones;
  357. }
  358. public function addValoracione(Valoracion $valoracione): self
  359. {
  360. if (!$this->valoraciones->contains($valoracione)) {
  361. $this->valoraciones[] = $valoracione;
  362. $valoracione->setCliente($this);
  363. }
  364. return $this;
  365. }
  366. public function removeValoracione(Valoracion $valoracione): self
  367. {
  368. if ($this->valoraciones->removeElement($valoracione)) {
  369. // set the owning side to null (unless already changed)
  370. if ($valoracione->getCliente() === $this) {
  371. $valoracione->setCliente(null);
  372. }
  373. }
  374. return $this;
  375. }
  376. /**
  377. * @return Collection|Operacion[]
  378. */
  379. public function getOperaciones(): Collection
  380. {
  381. return $this->operaciones;
  382. }
  383. public function addOperacione(Operacion $operacione): self
  384. {
  385. if (!$this->operaciones->contains($operacione)) {
  386. $this->operaciones[] = $operacione;
  387. $operacione->setCliente($this);
  388. }
  389. return $this;
  390. }
  391. public function removeOperacione(Operacion $operacione): self
  392. {
  393. if ($this->operaciones->removeElement($operacione)) {
  394. // set the owning side to null (unless already changed)
  395. if ($operacione->getCliente() === $this) {
  396. $operacione->setCliente(null);
  397. }
  398. }
  399. return $this;
  400. }
  401. public function getTelefono(): ?string
  402. {
  403. return $this->telefono;
  404. }
  405. public function setTelefono(?string $telefono): self
  406. {
  407. $this->telefono = $telefono;
  408. return $this;
  409. }
  410. public function getEmail(): ?string
  411. {
  412. return $this->email;
  413. }
  414. public function setEmail(?string $email): self
  415. {
  416. $this->email = $email;
  417. return $this;
  418. }
  419. public function getDireccion(): ?string
  420. {
  421. return $this->direccion;
  422. }
  423. public function setDireccion(?string $direccion): self
  424. {
  425. $this->direccion = $direccion;
  426. return $this;
  427. }
  428. public function getCp(): ?string
  429. {
  430. return $this->cp;
  431. }
  432. public function setCp(?string $cp): self
  433. {
  434. $this->cp = $cp;
  435. return $this;
  436. }
  437. public function getCiudad(): ?string
  438. {
  439. return $this->ciudad;
  440. }
  441. public function setCiudad(?string $ciudad): self
  442. {
  443. $this->ciudad = $ciudad;
  444. return $this;
  445. }
  446. public function getCcaa(): ?CCAA
  447. {
  448. return $this->ccaa;
  449. }
  450. public function setCcaa(?CCAA $ccaa): self
  451. {
  452. $this->ccaa = $ccaa;
  453. return $this;
  454. }
  455. public function getPais(): ?string
  456. {
  457. return $this->pais;
  458. }
  459. public function setPais(?string $pais): self
  460. {
  461. $this->pais = $pais;
  462. return $this;
  463. }
  464. public function getProvincia(): ?Provincia
  465. {
  466. return $this->provincia;
  467. }
  468. public function setProvincia(?Provincia $provincia): self
  469. {
  470. $this->provincia = $provincia;
  471. return $this;
  472. }
  473. /**
  474. * @return Collection<int, ActividadAbstract>
  475. */
  476. public function getActividades(): Collection
  477. {
  478. return $this->actividades;
  479. }
  480. public function addActividade(ActividadAbstract $actividade): static
  481. {
  482. if (!$this->actividades->contains($actividade)) {
  483. $this->actividades->add($actividade);
  484. $actividade->setCliente($this);
  485. }
  486. return $this;
  487. }
  488. public function removeActividade(ActividadAbstract $actividade): static
  489. {
  490. if ($this->actividades->removeElement($actividade)) {
  491. // set the owning side to null (unless already changed)
  492. if ($actividade->getCliente() === $this) {
  493. $actividade->setCliente(null);
  494. }
  495. }
  496. return $this;
  497. }
  498. public function getRegion(): ?string
  499. {
  500. return $this->region;
  501. }
  502. public function setRegion(?string $region): static
  503. {
  504. $this->region = $region;
  505. return $this;
  506. }
  507. public function getExportPais(): ?string
  508. {
  509. return $this->getPais() ? Countries::getName($this->getPais()) : null;
  510. }
  511. }