<?php
namespace App\Entity;
use App\Repository\UsuarioRepository;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UsuarioRepository::class)
* @ORM\HasLifecycleCallbacks
* @Orm\EntityListeners({App\Doctrine\UsuarioListener::class})
*/
class Usuario implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private string $cpf;
/**
* @ORM\Column(type="json")
*/
private array $roles = [];
/**
* @var string|null The hashed password
* @ORM\Column(type="string")
*/
private ?string $password = null;
/**
* @ORM\ManyToOne(targetEntity=UsuarioTipo::class, inversedBy="usuarios")
* @ORM\JoinColumn(nullable=false)
*/
private UsuarioTipo $usuarioTipo;
/**
* @ORM\Column(type="string", length=255)
*/
private string $email;
/**
* @ORM\Column(type="datetime")
*/
private DateTimeInterface $cadastroData;
/**
* @ORM\Column(type="string", length=255)
*/
private string $nome;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeInterface $confirmacaoEmailData;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $token = null;
/**
* @ORM\ManyToOne(targetEntity=Imovel::class)
* @ORM\JoinColumn(nullable=false)
*/
private ?Imovel $imovel;
/**
* @ORM\Column(type="boolean")
*/
private bool $verificado;
/**
* @ORM\Column(type="boolean")
*/
private bool $ativo;
public function getId(): ?int
{
return $this->id;
}
public function getCpf(): ?string
{
return $this->cpf;
}
public function setCpf(string $cpf): self
{
$this->cpf = $cpf;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->cpf;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->cpf;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getUsuarioTipo(): ?UsuarioTipo
{
return $this->usuarioTipo;
}
public function setUsuarioTipo(?UsuarioTipo $usuarioTipo): self
{
$this->usuarioTipo = $usuarioTipo;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getCadastroData(): ?\DateTimeInterface
{
return $this->cadastroData;
}
public function setCadastroData(\DateTimeInterface $cadastroData): self
{
$this->cadastroData = $cadastroData;
return $this;
}
public function getNome(): ?string
{
return $this->nome;
}
public function setNome(string $nome): self
{
$this->nome = $nome;
return $this;
}
public function getConfirmacaoEmailData(): ?DateTimeInterface
{
return $this->confirmacaoEmailData;
}
public function setConfirmacaoEmailData(?DateTimeInterface $confirmacaoEmailData): self
{
$this->confirmacaoEmailData = $confirmacaoEmailData;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getImovel(): ?Imovel
{
return $this->imovel;
}
public function setImovel(?Imovel $imovel): self
{
$this->imovel = $imovel;
return $this;
}
public function isVerificado(): ?bool
{
return $this->verificado;
}
public function setVerificado(bool $verificado): self
{
$this->verificado = $verificado;
return $this;
}
public function isAtivo(): bool
{
return $this->ativo;
}
public function setAtivo(bool $ativo): Usuario
{
$this->ativo = $ativo;
return $this;
}
}