src/Entity/FielpetPol/Usuario.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\FielpetPol;
  3. use App\Entity\Traits\LoggableTrait;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10. * Usuario
  11. *
  12. * @ORM\Table(name="usuario")
  13. * @ORM\Entity(repositoryClass="App\Repository\FielpetPol\UsuarioRepository")
  14. */
  15. class Usuario implements UserInterface, PasswordAuthenticatedUserInterface
  16. {
  17. /**
  18. * LoggableTrait add add_user_ add_date, edit_user, edit_date
  19. */
  20. use LoggableTrait;
  21. /**
  22. * @var integer
  23. *
  24. * @ORM\Column(name="id", type="integer", nullable=false)
  25. * @ORM\Id
  26. * @ORM\GeneratedValue(strategy="IDENTITY")
  27. */
  28. private $id;
  29. /**
  30. * @var string
  31. *
  32. * @ORM\Column(name="nombre", type="string", length=255, nullable=false)
  33. */
  34. private $nombre;
  35. /**
  36. * @var string
  37. *
  38. * @ORM\Column(name="apellido", type="string", length=255, nullable=false)
  39. */
  40. private $apellido;
  41. /**
  42. * @var string
  43. *
  44. * @ORM\Column(name="user", type="string", length=255, nullable=false)
  45. */
  46. private $user;
  47. /**
  48. * @var integer
  49. *
  50. * @ORM\Column(name="type", type="integer", nullable=false)
  51. */
  52. private $type;
  53. /**
  54. * @var string
  55. *
  56. * @ORM\Column(name="password", type="string", length=255, nullable=false)
  57. */
  58. private $password;
  59. /**
  60. * @var string
  61. *
  62. * @ORM\Column(name="email", type="string", length=255, nullable=true)
  63. */
  64. private $email;
  65. /**
  66. * @var \Date
  67. *
  68. * @ORM\Column(name="fecha_nacimiento", type="date", nullable=true)
  69. */
  70. private $fechaNacimiento;
  71. /**
  72. * @var string
  73. *
  74. * @ORM\Column(name="telefono", type="string", length=100, nullable=true)
  75. */
  76. private $telefono;
  77. /**
  78. * @var string
  79. *
  80. * @ORM\Column(name="api_key", type="string", length=100, nullable=true)
  81. */
  82. private $apiKey;
  83. /**
  84. *
  85. * @var \Datetime
  86. * @ORM\Column(name="last_activity_at", type="datetime", nullable=false, options={"default"="2010-01-01 00:00:00"})
  87. */
  88. private $lastActivityAt;
  89. /**
  90. * Get password
  91. *
  92. * @return string
  93. */
  94. public function getPassword(): String
  95. {
  96. return $this->password;
  97. }
  98. /**
  99. * Returns the salt that was originally used to encode the password.
  100. *
  101. * This can return null if the password was not encoded using a salt.
  102. *
  103. * @return string|null The salt
  104. */
  105. public function getSalt()
  106. {
  107. return '';
  108. }
  109. /**
  110. * Returns the username used to authenticate the user.
  111. *
  112. * @return string The username
  113. */
  114. public function getUsername()
  115. {
  116. return $this->getUser();
  117. }
  118. /**
  119. * Removes sensitive data from the user.
  120. *
  121. * This is important if, at any given point, sensitive information like
  122. * the plain-text password is stored on this object.
  123. */
  124. public function eraseCredentials()
  125. {
  126. // TODO: Implement eraseCredentials() method.
  127. }
  128. /**
  129. * Returns the roles granted to the user.
  130. *
  131. * <code>
  132. * public function getRoles()
  133. * {
  134. * return array('ROLE_USER');
  135. * }
  136. * </code>
  137. *
  138. * Alternatively, the roles might be stored on a ``roles`` property,
  139. * and populated in any number of different ways when the user object
  140. * is created.
  141. *
  142. * @return (Role|string)[] The user roles
  143. */
  144. public function getRoles()
  145. {
  146. if ($this->getType() == '1') {
  147. $rol = 'ROLE_ADMIN';
  148. } elseif ($this->getType() == '2') {
  149. $rol = 'ROLE_INBOUND';
  150. } elseif ($this->getType() == '3') {
  151. $rol = 'ROLE_TIGRE';
  152. } else {
  153. $rol = 'ROLE_USER';
  154. }
  155. return array($rol);
  156. }
  157. public function getId(): ?int
  158. {
  159. return $this->id;
  160. }
  161. public function getNombre(): ?string
  162. {
  163. return $this->nombre;
  164. }
  165. public function setNombre(string $nombre): static
  166. {
  167. $this->nombre = $nombre;
  168. return $this;
  169. }
  170. public function getApellido(): ?string
  171. {
  172. return $this->apellido;
  173. }
  174. public function setApellido(string $apellido): static
  175. {
  176. $this->apellido = $apellido;
  177. return $this;
  178. }
  179. public function getUser(): ?string
  180. {
  181. return $this->user;
  182. }
  183. public function setUser(string $user): static
  184. {
  185. $this->user = $user;
  186. return $this;
  187. }
  188. public function getType(): ?int
  189. {
  190. return $this->type;
  191. }
  192. public function setType(int $type): static
  193. {
  194. $this->type = $type;
  195. return $this;
  196. }
  197. public function setPassword(string $password): static
  198. {
  199. $this->password = $password;
  200. return $this;
  201. }
  202. public function getEmail(): ?string
  203. {
  204. return $this->email;
  205. }
  206. public function setEmail(?string $email): static
  207. {
  208. $this->email = $email;
  209. return $this;
  210. }
  211. public function getFechaNacimiento(): ?\DateTimeInterface
  212. {
  213. return $this->fechaNacimiento;
  214. }
  215. public function setFechaNacimiento(?\DateTimeInterface $fechaNacimiento): static
  216. {
  217. $this->fechaNacimiento = $fechaNacimiento;
  218. return $this;
  219. }
  220. public function getTelefono(): ?string
  221. {
  222. return $this->telefono;
  223. }
  224. public function setTelefono(?string $telefono): static
  225. {
  226. $this->telefono = $telefono;
  227. return $this;
  228. }
  229. /**
  230. * Set lastActivityAt
  231. *
  232. * @param \DateTime $lastActivityAt
  233. *
  234. * @return Users
  235. */
  236. public function setLastActivityAt($lastActivityAt)
  237. {
  238. $this->lastActivityAt = $lastActivityAt;
  239. return $this;
  240. }
  241. /**
  242. * Get lastActivityAt
  243. *
  244. * @return \DateTime
  245. */
  246. public function getLastActivityAt()
  247. {
  248. return $this->lastActivityAt;
  249. }
  250. public function getApiKey(): string
  251. {
  252. return $this->apiKey;
  253. }
  254. public function setApiKey(string $apiKey): void
  255. {
  256. $this->apiKey = $apiKey;
  257. }
  258. }