src/Entity/User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. /**
  8. * @ORM\Entity(repositoryClass=UserRepository::class)
  9. * @ORM\Table(name="`user`")
  10. */
  11. class User implements UserInterface, PasswordAuthenticatedUserInterface
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string", length=180, unique=true)
  21. */
  22. private $email;
  23. /**
  24. * @ORM\Column(type="string", length=1)
  25. */
  26. private $active;
  27. /**
  28. * @ORM\Column(type="json", nullable=true)
  29. */
  30. private $roles = [];
  31. /**
  32. * @var string The hashed password
  33. * @ORM\Column(type="string")
  34. */
  35. private $password;
  36. /**
  37. * @ORM\Column(type="string", length=255)
  38. */
  39. private $name;
  40. /**
  41. * @ORM\Column(type="string", length=255, unique=true)
  42. */
  43. private $ucode;
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getEmail(): ?string
  49. {
  50. return $this->email;
  51. }
  52. public function setEmail(string $email): self
  53. {
  54. $this->email = $email;
  55. return $this;
  56. }
  57. /**
  58. * A visual identifier that represents this user.
  59. *
  60. * @see UserInterface
  61. */
  62. public function getUserIdentifier(): string
  63. {
  64. return (string) $this->email;
  65. }
  66. /**
  67. * @deprecated since Symfony 5.3, use getUserIdentifier instead
  68. */
  69. public function getUsername(): string
  70. {
  71. return (string) $this->email;
  72. }
  73. /**
  74. * @see UserInterface
  75. */
  76. public function getRoles(): array
  77. {
  78. $roles = $this->roles;
  79. // guarantee every user at least has ROLE_USER
  80. $roles[] = 'ROLE_USER';
  81. return array_unique($roles);
  82. }
  83. public function setRoles(array $roles): self
  84. {
  85. $this->roles = $roles;
  86. return $this;
  87. }
  88. /**
  89. * @see PasswordAuthenticatedUserInterface
  90. */
  91. public function getPassword(): string
  92. {
  93. return $this->password;
  94. }
  95. public function setPassword(string $password): self
  96. {
  97. $this->password = $password;
  98. return $this;
  99. }
  100. /**
  101. * Returning a salt is only needed, if you are not using a modern
  102. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  103. *
  104. * @see UserInterface
  105. */
  106. public function getSalt(): ?string
  107. {
  108. return null;
  109. }
  110. /**
  111. * @see UserInterface
  112. */
  113. public function eraseCredentials()
  114. {
  115. // If you store any temporary, sensitive data on the user, clear it here
  116. // $this->plainPassword = null;
  117. }
  118. public function getName(): ?string
  119. {
  120. return $this->name;
  121. }
  122. public function getUcode(): ?string
  123. {
  124. return $this->ucode;
  125. }
  126. public function setName(string $name): self
  127. {
  128. $this->name = $name;
  129. return $this;
  130. }
  131. public function setUcode(string $ucode): self
  132. {
  133. $this->ucode = $ucode;
  134. return $this;
  135. }
  136. public function getActive(): ?string
  137. {
  138. return $this->active;
  139. }
  140. public function setActive(string $active): self
  141. {
  142. $this->active = $active;
  143. return $this;
  144. }
  145. }