src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubscriptionRepository;
  4. use App\Repository\UserRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. /**
  11. * @ORM\Entity(repositoryClass=UserRepository::class)
  12. */
  13. class User implements UserInterface, PasswordAuthenticatedUserInterface
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\Column(type="string", length=180, nullable=true)
  23. */
  24. private $email;
  25. /**
  26. * @ORM\Column(type="json")
  27. */
  28. private $roles = [];
  29. /**
  30. * @var string The hashed password
  31. * @ORM\Column(type="string")
  32. */
  33. private $password;
  34. /**
  35. * @ORM\Column(type="string", length=250, nullable=true)
  36. */
  37. private $Nombre;
  38. /**
  39. * @ORM\Column(type="string", length=25, nullable=true)
  40. */
  41. private $Apellido1;
  42. /**
  43. * @ORM\Column(type="string", length=25, nullable=true)
  44. */
  45. private $Apellido2;
  46. /**
  47. * @ORM\Column(type="string", length=15, unique=true)
  48. */
  49. private $tel1;
  50. /**
  51. * @ORM\Column(type="boolean", options={"default"=1})
  52. */
  53. private $isActivo;
  54. /**
  55. * @ORM\Column(type="datetime_immutable")
  56. */
  57. private $createdAt;
  58. /**
  59. * @ORM\Column(type="datetime_immutable")
  60. */
  61. private $updatedAt;
  62. /**
  63. * @ORM\Column(type="string", length=1000, nullable=true)
  64. */
  65. private $comentarios;
  66. /**
  67. * @ORM\Column(type="string", length=255, nullable=true)
  68. */
  69. private $stripeId;
  70. /**
  71. * @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="user")
  72. */
  73. private $subscriptions;
  74. /**
  75. * @ORM\Column(type="string", length=255, nullable=true)
  76. */
  77. private $plainPassword;
  78. /**
  79. * @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="seller")
  80. */
  81. private $soldSubscriptions;
  82. /**
  83. * @ORM\OneToMany(targetEntity=Payout::class, mappedBy="seller")
  84. */
  85. private $payouts;
  86. /**
  87. * @ORM\Column(type="date", nullable=true)
  88. */
  89. private $dob;
  90. /**
  91. * @ORM\Column(type="boolean", nullable=true)
  92. */
  93. private $resetPin;
  94. /**
  95. * @ORM\Column(type="integer", nullable=true)
  96. */
  97. private $clienteId;
  98. /**
  99. * @ORM\OneToMany(targetEntity=Orden::class, mappedBy="user")
  100. */
  101. private $ordenes;
  102. /**
  103. * @ORM\OneToMany(targetEntity=PaymentIntent::class, mappedBy="user")
  104. */
  105. private $paymentIntents;
  106. /**
  107. * @ORM\Column(type="string", length=255, nullable=true)
  108. */
  109. private $subscriptionStatus;
  110. /**
  111. * @ORM\Column(type="datetime", nullable=true)
  112. */
  113. private $lastSubscriptionDate;
  114. /**
  115. * @ORM\Column(type="datetime_immutable", nullable=true)
  116. */
  117. private $lastExpiresAt;
  118. /**
  119. * @ORM\Column(type="integer", nullable=true)
  120. */
  121. private $userId;
  122. /**
  123. * @ORM\OneToMany(targetEntity=MailingLog::class, mappedBy="user")
  124. */
  125. private $mailingLogs;
  126. /**
  127. * @ORM\Column(type="string", length=255, nullable=true)
  128. */
  129. private $nombreCompleto;
  130. /**
  131. * @ORM\Column(type="string", length=255, nullable=true)
  132. */
  133. private $sendgridId;
  134. /**
  135. * @ORM\ManyToOne(targetEntity=MailingList::class, inversedBy="users")
  136. */
  137. private $mailingList;
  138. /**
  139. * @ORM\ManyToOne(targetEntity=PromoCode::class, inversedBy="usedUsers")
  140. */
  141. private $usedPromoCode;
  142. /**
  143. * @ORM\Column(type="string", length=255, nullable=true)
  144. */
  145. private $sendgridStatus;
  146. /**
  147. * @ORM\Column(type="boolean", options={"default"=0})
  148. */
  149. private $sendgridIgnore;
  150. /**
  151. * @ORM\OneToMany(targetEntity=Solicitud::class, mappedBy="user")
  152. */
  153. private $solicitudes;
  154. /**
  155. * @ORM\Column(type="string", length=255, nullable=true)
  156. */
  157. private $directCode;
  158. public function __construct()
  159. {
  160. if(!$this->createdAt) $this->createdAt = new \DateTimeImmutable();
  161. $this->updatedAt = new \DateTimeImmutable();
  162. if(!$this->password) $this->password = '1234';
  163. $this->subscriptions = new ArrayCollection();
  164. $this->soldSubscriptions = new ArrayCollection();
  165. $this->payouts = new ArrayCollection();
  166. $this->ordenes = new ArrayCollection();
  167. $this->paymentIntents = new ArrayCollection();
  168. $this->mailingLogs = new ArrayCollection();
  169. if(!$this->sendgridStatus) $this->sendgridStatus = 'Renovado';
  170. $this->solicitudes = new ArrayCollection();
  171. }
  172. public function getId(): ?int
  173. {
  174. return $this->id;
  175. }
  176. public function getEmail(): ?string
  177. {
  178. return $this->email;
  179. }
  180. public function setEmail(?string $email): self
  181. {
  182. $this->email = $email;
  183. return $this;
  184. }
  185. /**
  186. * A visual identifier that represents this user.
  187. *
  188. * @see UserInterface
  189. */
  190. public function getUserIdentifier(): string
  191. {
  192. return (string) $this->tel1;
  193. }
  194. /**
  195. * @deprecated since Symfony 5.3, use getUserIdentifier instead
  196. */
  197. public function getUsername(): string
  198. {
  199. return (string) $this->email;
  200. }
  201. /**
  202. * @see UserInterface
  203. */
  204. public function getRoles(): array
  205. {
  206. $roles = $this->roles;
  207. // guarantee every user at least has ROLE_USER
  208. $roles[] = 'ROLE_USER';
  209. return array_unique($roles);
  210. }
  211. public function setRoles(array $roles): self
  212. {
  213. $this->roles = $roles;
  214. return $this;
  215. }
  216. /**
  217. * @see PasswordAuthenticatedUserInterface
  218. */
  219. public function getPassword(): string
  220. {
  221. return $this->password;
  222. }
  223. public function setPassword(string $password): self
  224. {
  225. $this->password = $password;
  226. return $this;
  227. }
  228. /**
  229. * Returning a salt is only needed, if you are not using a modern
  230. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  231. *
  232. * @see UserInterface
  233. */
  234. public function getSalt(): ?string
  235. {
  236. return null;
  237. }
  238. /**
  239. * @see UserInterface
  240. */
  241. public function eraseCredentials()
  242. {
  243. // If you store any temporary, sensitive data on the user, clear it here
  244. // $this->plainPassword = null;
  245. }
  246. public function getNombre(): ?string
  247. {
  248. return $this->Nombre;
  249. }
  250. public function setNombre(?string $Nombre): self
  251. {
  252. $this->Nombre = $Nombre;
  253. return $this;
  254. }
  255. public function getApellido1(): ?string
  256. {
  257. return $this->Apellido1;
  258. }
  259. public function setApellido1(?string $Apellido1): self
  260. {
  261. $this->Apellido1 = $Apellido1;
  262. return $this;
  263. }
  264. public function getApellido2(): ?string
  265. {
  266. return $this->Apellido2;
  267. }
  268. public function setApellido2(?string $Apellido2): self
  269. {
  270. $this->Apellido2 = $Apellido2;
  271. return $this;
  272. }
  273. public function getTel1(): ?string
  274. {
  275. return $this->tel1;
  276. }
  277. public function setTel1(?string $tel1): self
  278. {
  279. $this->tel1 = $tel1;
  280. return $this;
  281. }
  282. public function getIsActivo(): ?bool
  283. {
  284. return $this->isActivo;
  285. }
  286. public function setIsActivo(bool $isActivo): self
  287. {
  288. $this->isActivo = $isActivo;
  289. return $this;
  290. }
  291. public function getCreatedAt(): ?\DateTimeImmutable
  292. {
  293. return $this->createdAt;
  294. }
  295. public function setCreatedAt(\DateTimeImmutable $createdAt): self
  296. {
  297. $this->createdAt = $createdAt;
  298. return $this;
  299. }
  300. public function getUpdatedAt(): ?\DateTimeImmutable
  301. {
  302. return $this->updatedAt;
  303. }
  304. public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  305. {
  306. $this->updatedAt = $updatedAt;
  307. return $this;
  308. }
  309. public function getComentarios(): ?string
  310. {
  311. return $this->comentarios;
  312. }
  313. public function setComentarios(?string $comentarios): self
  314. {
  315. $this->comentarios = $comentarios;
  316. return $this;
  317. }
  318. public function getStripeId(): ?string
  319. {
  320. return $this->stripeId;
  321. }
  322. public function setStripeId(?string $stripeId): self
  323. {
  324. $this->stripeId = $stripeId;
  325. return $this;
  326. }
  327. public function __toString()
  328. {
  329. if($this->getNombre()){
  330. return $this->getNombre() . ' ' . $this->getApellido1();
  331. }else{
  332. return $this->getNombreCompleto();
  333. }
  334. }
  335. /**
  336. * @return Collection<int, Subscription>
  337. */
  338. public function getSubscriptions(): Collection
  339. {
  340. return $this->subscriptions;
  341. }
  342. public function getActiveSubscriptions()
  343. {
  344. $r = [];
  345. $r = $this->getSubscriptions()->filter(function (Subscription $sub) {
  346. return $sub->getCurrentPlace() == 'Activa';
  347. // return in_array($sub->getCurrentPlace(), ['Activa', 'Activa 15d']);
  348. });
  349. return $r->toArray();
  350. }
  351. public function getActive15Subscriptions()
  352. {
  353. $r = [];
  354. $r = $this->getSubscriptions()->filter(function (Subscription $sub) {
  355. return $sub->getCurrentPlace() == 'Activa 15d';
  356. // return in_array($sub->getCurrentPlace(), ['Activa', 'Activa 15d']);
  357. });
  358. return $r->toArray();
  359. }
  360. public function addSubscription(Subscription $subscription): self
  361. {
  362. if (!$this->subscriptions->contains($subscription)) {
  363. $this->subscriptions[] = $subscription;
  364. $subscription->setUser($this);
  365. }
  366. return $this;
  367. }
  368. public function removeSubscription(Subscription $subscription): self
  369. {
  370. if ($this->subscriptions->removeElement($subscription)) {
  371. // set the owning side to null (unless already changed)
  372. if ($subscription->getUser() === $this) {
  373. $subscription->setUser(null);
  374. }
  375. }
  376. return $this;
  377. }
  378. public function getPlainPassword(): ?string
  379. {
  380. return $this->plainPassword;
  381. }
  382. public function setPlainPassword(?string $plainPassword): self
  383. {
  384. $this->plainPassword = $plainPassword;
  385. return $this;
  386. }
  387. /**
  388. * @return Collection<int, Subscription>
  389. */
  390. public function getSoldSubscriptions(): Collection
  391. {
  392. return $this->soldSubscriptions;
  393. }
  394. public function addSoldSubscription(Subscription $soldSubscription): self
  395. {
  396. if (!$this->soldSubscriptions->contains($soldSubscription)) {
  397. $this->soldSubscriptions[] = $soldSubscription;
  398. $soldSubscription->setSeller($this);
  399. }
  400. return $this;
  401. }
  402. public function removeSoldSubscription(Subscription $soldSubscription): self
  403. {
  404. if ($this->soldSubscriptions->removeElement($soldSubscription)) {
  405. // set the owning side to null (unless already changed)
  406. if ($soldSubscription->getSeller() === $this) {
  407. $soldSubscription->setSeller(null);
  408. }
  409. }
  410. return $this;
  411. }
  412. /**
  413. * @return Collection<int, Payout>
  414. */
  415. public function getPayouts(): Collection
  416. {
  417. return $this->payouts;
  418. }
  419. public function addPayout(Payout $payout): self
  420. {
  421. if (!$this->payouts->contains($payout)) {
  422. $this->payouts[] = $payout;
  423. $payout->setSeller($this);
  424. }
  425. return $this;
  426. }
  427. public function removePayout(Payout $payout): self
  428. {
  429. if ($this->payouts->removeElement($payout)) {
  430. // set the owning side to null (unless already changed)
  431. if ($payout->getSeller() === $this) {
  432. $payout->setSeller(null);
  433. }
  434. }
  435. return $this;
  436. }
  437. public function getDob(): ?\DateTimeInterface
  438. {
  439. return $this->dob;
  440. }
  441. public function setDob(?\DateTimeInterface $dob): self
  442. {
  443. $this->dob = $dob;
  444. return $this;
  445. }
  446. public function getResetPin(): ?bool
  447. {
  448. return $this->resetPin;
  449. }
  450. public function setResetPin(?bool $resetPin): self
  451. {
  452. $this->resetPin = $resetPin;
  453. return $this;
  454. }
  455. public function isHasSubscriptionActiva(): ?bool
  456. {
  457. return $this->hasSubscriptionActiva;
  458. }
  459. public function setHasSubscriptionActiva(?bool $hasSubscriptionActiva): self
  460. {
  461. $this->hasSubscriptionActiva = $hasSubscriptionActiva;
  462. return $this;
  463. }
  464. public function getClienteId(): ?int
  465. {
  466. return $this->clienteId;
  467. }
  468. public function setClienteId(?int $clienteId): self
  469. {
  470. $this->clienteId = $clienteId;
  471. return $this;
  472. }
  473. /**
  474. * @return Collection<int, Orden>
  475. */
  476. public function getOrdenes(): Collection
  477. {
  478. return $this->ordenes;
  479. }
  480. public function addOrdene(Orden $ordene): self
  481. {
  482. if (!$this->ordenes->contains($ordene)) {
  483. $this->ordenes[] = $ordene;
  484. $ordene->setUser($this);
  485. }
  486. return $this;
  487. }
  488. public function removeOrdene(Orden $ordene): self
  489. {
  490. if ($this->ordenes->removeElement($ordene)) {
  491. // set the owning side to null (unless already changed)
  492. if ($ordene->getUser() === $this) {
  493. $ordene->setUser(null);
  494. }
  495. }
  496. return $this;
  497. }
  498. /**
  499. * @return Collection<int, PaymentIntent>
  500. */
  501. public function getPaymentIntents(): Collection
  502. {
  503. return $this->paymentIntents;
  504. }
  505. public function addPaymentIntent(PaymentIntent $paymentIntent): self
  506. {
  507. if (!$this->paymentIntents->contains($paymentIntent)) {
  508. $this->paymentIntents[] = $paymentIntent;
  509. $paymentIntent->setUser($this);
  510. }
  511. return $this;
  512. }
  513. public function removePaymentIntent(PaymentIntent $paymentIntent): self
  514. {
  515. if ($this->paymentIntents->removeElement($paymentIntent)) {
  516. // set the owning side to null (unless already changed)
  517. if ($paymentIntent->getUser() === $this) {
  518. $paymentIntent->setUser(null);
  519. }
  520. }
  521. return $this;
  522. }
  523. public function getSubscriptionStatus(): ?string
  524. {
  525. return $this->subscriptionStatus;
  526. }
  527. public function setSubscriptionStatus(?string $subscriptionStatus): self
  528. {
  529. $this->subscriptionStatus = $subscriptionStatus;
  530. return $this;
  531. }
  532. public function getLastSubscriptionDate(): ?\DateTimeInterface
  533. {
  534. return $this->lastSubscriptionDate;
  535. }
  536. public function setLastSubscriptionDate(?\DateTimeInterface $lastSubscriptionDate): self
  537. {
  538. $this->lastSubscriptionDate = $lastSubscriptionDate;
  539. return $this;
  540. }
  541. public function getLastExpiresAt(): ?\DateTimeImmutable
  542. {
  543. return $this->lastExpiresAt;
  544. }
  545. public function setLastExpiresAt(?\DateTimeImmutable $lastExpiresAt): self
  546. {
  547. $this->lastExpiresAt = $lastExpiresAt;
  548. return $this;
  549. }
  550. public function getUserId(): ?int
  551. {
  552. return $this->userId;
  553. }
  554. public function setUserId(?int $userId): self
  555. {
  556. $this->userId = $userId;
  557. return $this;
  558. }
  559. /**
  560. * @return Collection<int, MailingLog>
  561. */
  562. public function getMailingLogs(): Collection
  563. {
  564. return $this->mailingLogs;
  565. }
  566. public function addMailingLog(MailingLog $mailingLog): self
  567. {
  568. if (!$this->mailingLogs->contains($mailingLog)) {
  569. $this->mailingLogs[] = $mailingLog;
  570. $mailingLog->setUser($this);
  571. }
  572. return $this;
  573. }
  574. public function removeMailingLog(MailingLog $mailingLog): self
  575. {
  576. if ($this->mailingLogs->removeElement($mailingLog)) {
  577. // set the owning side to null (unless already changed)
  578. if ($mailingLog->getUser() === $this) {
  579. $mailingLog->setUser(null);
  580. }
  581. }
  582. return $this;
  583. }
  584. public function getNombreCompleto(): ?string
  585. {
  586. return $this->nombreCompleto;
  587. }
  588. public function setNombreCompleto(?string $nombreCompleto): self
  589. {
  590. $this->nombreCompleto = $nombreCompleto;
  591. return $this;
  592. }
  593. public function getSendgridId(): ?string
  594. {
  595. return $this->sendgridId;
  596. }
  597. public function setSendgridId(?string $sendgridId): self
  598. {
  599. $this->sendgridId = $sendgridId;
  600. return $this;
  601. }
  602. public function getMailingList(): ?MailingList
  603. {
  604. return $this->mailingList;
  605. }
  606. public function setMailingList(?MailingList $mailingList): self
  607. {
  608. $this->mailingList = $mailingList;
  609. return $this;
  610. }
  611. public function getUsedPromoCode(): ?PromoCode
  612. {
  613. return $this->usedPromoCode;
  614. }
  615. public function setUsedPromoCode(?PromoCode $usedPromoCode): self
  616. {
  617. $this->usedPromoCode = $usedPromoCode;
  618. return $this;
  619. }
  620. public function getSendgridStatus(): ?string
  621. {
  622. return $this->sendgridStatus;
  623. }
  624. public function setSendgridStatus(string $sendgridStatus): self
  625. {
  626. $this->sendgridStatus = $sendgridStatus;
  627. return $this;
  628. }
  629. public function getSendgridIgnore(): ?bool
  630. {
  631. return $this->sendgridIgnore;
  632. }
  633. public function setSendgridIgnore(bool $sendgridIgnore): self
  634. {
  635. $this->sendgridIgnore = $sendgridIgnore;
  636. return $this;
  637. }
  638. /**
  639. * @return Collection<int, Solicitud>
  640. */
  641. public function getSolicitudes(): Collection
  642. {
  643. return $this->solicitudes;
  644. }
  645. public function addSolicitude(Solicitud $solicitude): self
  646. {
  647. if (!$this->solicitudes->contains($solicitude)) {
  648. $this->solicitudes[] = $solicitude;
  649. $solicitude->setUser($this);
  650. }
  651. return $this;
  652. }
  653. public function removeSolicitude(Solicitud $solicitude): self
  654. {
  655. if ($this->solicitudes->removeElement($solicitude)) {
  656. // set the owning side to null (unless already changed)
  657. if ($solicitude->getUser() === $this) {
  658. $solicitude->setUser(null);
  659. }
  660. }
  661. return $this;
  662. }
  663. public function getDirectCode(): ?string
  664. {
  665. return $this->directCode;
  666. }
  667. public function setDirectCode(?string $directCode): self
  668. {
  669. $this->directCode = $directCode;
  670. return $this;
  671. }
  672. }