<?php
namespace App\Entity\FielpetPol;
use App\Entity\Traits\LoggableTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Usuario
*
* @ORM\Table(name="usuario")
* @ORM\Entity(repositoryClass="App\Repository\FielpetPol\UsuarioRepository")
*/
class Usuario implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* LoggableTrait add add_user_ add_date, edit_user, edit_date
*/
use LoggableTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nombre", type="string", length=255, nullable=false)
*/
private $nombre;
/**
* @var string
*
* @ORM\Column(name="apellido", type="string", length=255, nullable=false)
*/
private $apellido;
/**
* @var string
*
* @ORM\Column(name="user", type="string", length=255, nullable=false)
*/
private $user;
/**
* @var integer
*
* @ORM\Column(name="type", type="integer", nullable=false)
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255, nullable=false)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* @var \Date
*
* @ORM\Column(name="fecha_nacimiento", type="date", nullable=true)
*/
private $fechaNacimiento;
/**
* @var string
*
* @ORM\Column(name="telefono", type="string", length=100, nullable=true)
*/
private $telefono;
/**
* @var string
*
* @ORM\Column(name="api_key", type="string", length=100, nullable=true)
*/
private $apiKey;
/**
*
* @var \Datetime
* @ORM\Column(name="last_activity_at", type="datetime", nullable=false, options={"default"="2010-01-01 00:00:00"})
*/
private $lastActivityAt;
/**
* Get password
*
* @return string
*/
public function getPassword(): String
{
return $this->password;
}
/**
* Returns the salt that was originally used to encode the password.
*
* This can return null if the password was not encoded using a salt.
*
* @return string|null The salt
*/
public function getSalt()
{
return '';
}
/**
* Returns the username used to authenticate the user.
*
* @return string The username
*/
public function getUsername()
{
return $this->getUser();
}
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* @return (Role|string)[] The user roles
*/
public function getRoles()
{
if ($this->getType() == '1') {
$rol = 'ROLE_ADMIN';
} elseif ($this->getType() == '2') {
$rol = 'ROLE_INBOUND';
} elseif ($this->getType() == '3') {
$rol = 'ROLE_TIGRE';
} else {
$rol = 'ROLE_USER';
}
return array($rol);
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): static
{
$this->nombre = $nombre;
return $this;
}
public function getApellido(): ?string
{
return $this->apellido;
}
public function setApellido(string $apellido): static
{
$this->apellido = $apellido;
return $this;
}
public function getUser(): ?string
{
return $this->user;
}
public function setUser(string $user): static
{
$this->user = $user;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): static
{
$this->type = $type;
return $this;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->email = $email;
return $this;
}
public function getFechaNacimiento(): ?\DateTimeInterface
{
return $this->fechaNacimiento;
}
public function setFechaNacimiento(?\DateTimeInterface $fechaNacimiento): static
{
$this->fechaNacimiento = $fechaNacimiento;
return $this;
}
public function getTelefono(): ?string
{
return $this->telefono;
}
public function setTelefono(?string $telefono): static
{
$this->telefono = $telefono;
return $this;
}
/**
* Set lastActivityAt
*
* @param \DateTime $lastActivityAt
*
* @return Users
*/
public function setLastActivityAt($lastActivityAt)
{
$this->lastActivityAt = $lastActivityAt;
return $this;
}
/**
* Get lastActivityAt
*
* @return \DateTime
*/
public function getLastActivityAt()
{
return $this->lastActivityAt;
}
public function getApiKey(): string
{
return $this->apiKey;
}
public function setApiKey(string $apiKey): void
{
$this->apiKey = $apiKey;
}
}