<?phpnamespace App\Entity;use App\Repository\UsuarioRepository;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Security\Core\User\UserInterface;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;/** * @ORM\Entity(repositoryClass=UsuarioRepository::class) * @ORM\Table(name="user") * @UniqueEntity("email") * @UniqueEntity("username") */class Usuario implements UserInterface{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=180, unique=true) */ private $email; /** * @ORM\Column(type="string", length=255) */ private $username; /** * @ORM\Column(type="string", length=255) */ private $nombre; /** * @ORM\Column(type="string", length=255) */ private $apellidos; /** * @ORM\Column(type="datetime") */ private $fechaAlta; /** * @ORM\Column(type="datetime", nullable=true) */ private $fechaUltimoLogin; /** * @ORM\Column(type="json") */ private $roles = []; /** * @var string The hashed password * @ORM\Column(type="string") */ private $password; /** * @var string */ private $plainPassword; /** * @ORM\Column(type="boolean") */ private $enabled = true; /** * @ORM\Column(type="datetime", nullable=true) */ private $ultimoAcceso; public function __construct() { } public function __toString(): string { return $this->getNombreCompleto(); } /** * @see UserInterface */ public function eraseCredentials() { $this->plainPassword = null; } /** * @see UserInterface */ public function getSalt() { } /** * @see UserInterface */ public function getUserIdentifier() { return $this->getUsername(); } public function getId(): ?int { return $this->id; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): self { $this->email = $email; return $this; } public function getUsername(): ?string { return $this->username; } public function setUsername(string $username): self { $this->username = $username; return $this; } public function getNombreCompleto(): ?string { return $this->nombre . ' ' . $this->apellidos; } public function getNombre(): ?string { return $this->nombre; } public function setNombre(string $nombre): self { $this->nombre = $nombre; return $this; } public function getApellidos(): ?string { return $this->apellidos; } public function setApellidos(string $apellidos): self { $this->apellidos = $apellidos; return $this; } public function getFechaAlta(): ?\DateTimeInterface { return $this->fechaAlta; } public function setFechaAlta(\DateTimeInterface $fechaAlta): self { $this->fechaAlta = $fechaAlta; return $this; } public function getFechaUltimoLogin(): ?\DateTimeInterface { return $this->fechaUltimoLogin; } public function setFechaUltimoLogin(?\DateTimeInterface $fechaUltimoLogin): self { $this->fechaUltimoLogin = $fechaUltimoLogin; return $this; } /** * @see UserInterface */ public function getRoles(): array { $roles = $this->roles; return array_unique($roles); } public function setRoles(array $roles): self { $this->roles = $roles; return $this; } public function hasRole(string $role): bool { return in_array($role, $this->getRoles()); } public function getRole(): string { return $this->roles ? $this->roles[0] : null; } /** * @see UserInterface */ public function getPassword(): string { return (string) $this->password; } public function setPassword(string $password): self { $this->password = $password; return $this; } public function getPlainPassword(): ?string { return $this->plainPassword; } public function setPlainPassword(string $plainPassword): self { $this->plainPassword = $plainPassword; return $this; } public function getEnabled(): ?bool { return $this->enabled; } public function setEnabled(bool $enabled): self { $this->enabled = $enabled; return $this; } public function getUltimoAcceso(): ?\DateTimeInterface { return $this->ultimoAcceso; } public function setUltimoAcceso(\DateTimeInterface $ultimoAcceso): self { $this->ultimoAcceso = $ultimoAcceso; return $this; }}