src/Entity/Usuario.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsuarioRepository;
  4. use DateTimeInterface;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. /**
  9.  * @ORM\Entity(repositoryClass=UsuarioRepository::class)
  10.  * @ORM\HasLifecycleCallbacks
  11.  * @Orm\EntityListeners({App\Doctrine\UsuarioListener::class})
  12.  */
  13. class Usuario implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private int $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=180, unique=true)
  23.      */
  24.     private string $cpf;
  25.     /**
  26.      * @ORM\Column(type="json")
  27.      */
  28.     private array $roles = [];
  29.     /**
  30.      * @var string|null The hashed password
  31.      * @ORM\Column(type="string")
  32.      */
  33.     private ?string $password null;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=UsuarioTipo::class, inversedBy="usuarios")
  36.      * @ORM\JoinColumn(nullable=false)
  37.      */
  38.     private UsuarioTipo $usuarioTipo;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private string $email;
  43.     /**
  44.      * @ORM\Column(type="datetime")
  45.      */
  46.     private DateTimeInterface $cadastroData;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private string $nome;
  51.     /**
  52.      * @ORM\Column(type="datetime", nullable=true)
  53.      */
  54.     private ?DateTimeInterface $confirmacaoEmailData;
  55.     /**
  56.      * @ORM\Column(type="string", length=255, nullable=true)
  57.      */
  58.     private ?string $token null;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=Imovel::class)
  61.      * @ORM\JoinColumn(nullable=false)
  62.      */
  63.     private ?Imovel $imovel;
  64.     /**
  65.      * @ORM\Column(type="boolean")
  66.      */
  67.     private bool $verificado;
  68.     /**
  69.      * @ORM\Column(type="boolean")
  70.      */
  71.     private bool $ativo;
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getCpf(): ?string
  77.     {
  78.         return $this->cpf;
  79.     }
  80.     public function setCpf(string $cpf): self
  81.     {
  82.         $this->cpf $cpf;
  83.         return $this;
  84.     }
  85.     /**
  86.      * A visual identifier that represents this user.
  87.      *
  88.      * @see UserInterface
  89.      */
  90.     public function getUserIdentifier(): string
  91.     {
  92.         return (string) $this->cpf;
  93.     }
  94.     /**
  95.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  96.      */
  97.     public function getUsername(): string
  98.     {
  99.         return (string) $this->cpf;
  100.     }
  101.     /**
  102.      * @see UserInterface
  103.      */
  104.     public function getRoles(): array
  105.     {
  106.         $roles $this->roles;
  107.         // guarantee every user at least has ROLE_USER
  108.         $roles[] = 'ROLE_USER';
  109.         return array_unique($roles);
  110.     }
  111.     public function setRoles(array $roles): self
  112.     {
  113.         $this->roles $roles;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @see PasswordAuthenticatedUserInterface
  118.      */
  119.     public function getPassword(): ?string
  120.     {
  121.         return $this->password;
  122.     }
  123.     public function setPassword(?string $password): self
  124.     {
  125.         $this->password $password;
  126.         return $this;
  127.     }
  128.     /**
  129.      * Returning a salt is only needed, if you are not using a modern
  130.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  131.      *
  132.      * @see UserInterface
  133.      */
  134.     public function getSalt(): ?string
  135.     {
  136.         return null;
  137.     }
  138.     /**
  139.      * @see UserInterface
  140.      */
  141.     public function eraseCredentials()
  142.     {
  143.         // If you store any temporary, sensitive data on the user, clear it here
  144.         // $this->plainPassword = null;
  145.     }
  146.     public function getUsuarioTipo(): ?UsuarioTipo
  147.     {
  148.         return $this->usuarioTipo;
  149.     }
  150.     public function setUsuarioTipo(?UsuarioTipo $usuarioTipo): self
  151.     {
  152.         $this->usuarioTipo $usuarioTipo;
  153.         return $this;
  154.     }
  155.     public function getEmail(): ?string
  156.     {
  157.         return $this->email;
  158.     }
  159.     public function setEmail(string $email): self
  160.     {
  161.         $this->email $email;
  162.         return $this;
  163.     }
  164.     public function getCadastroData(): ?\DateTimeInterface
  165.     {
  166.         return $this->cadastroData;
  167.     }
  168.     public function setCadastroData(\DateTimeInterface $cadastroData): self
  169.     {
  170.         $this->cadastroData $cadastroData;
  171.         return $this;
  172.     }
  173.     public function getNome(): ?string
  174.     {
  175.         return $this->nome;
  176.     }
  177.     public function setNome(string $nome): self
  178.     {
  179.         $this->nome $nome;
  180.         return $this;
  181.     }
  182.     public function getConfirmacaoEmailData(): ?DateTimeInterface
  183.     {
  184.         return $this->confirmacaoEmailData;
  185.     }
  186.     public function setConfirmacaoEmailData(?DateTimeInterface $confirmacaoEmailData): self
  187.     {
  188.         $this->confirmacaoEmailData $confirmacaoEmailData;
  189.         return $this;
  190.     }
  191.     public function getToken(): ?string
  192.     {
  193.         return $this->token;
  194.     }
  195.     public function setToken(?string $token): self
  196.     {
  197.         $this->token $token;
  198.         return $this;
  199.     }
  200.     public function getImovel(): ?Imovel
  201.     {
  202.         return $this->imovel;
  203.     }
  204.     public function setImovel(?Imovel $imovel): self
  205.     {
  206.         $this->imovel $imovel;
  207.         return $this;
  208.     }
  209.     public function isVerificado(): ?bool
  210.     {
  211.         return $this->verificado;
  212.     }
  213.     public function setVerificado(bool $verificado): self
  214.     {
  215.         $this->verificado $verificado;
  216.         return $this;
  217.     }
  218.     public function isAtivo(): bool
  219.     {
  220.         return $this->ativo;
  221.     }
  222.     public function setAtivo(bool $ativo): Usuario
  223.     {
  224.         $this->ativo $ativo;
  225.         return $this;
  226.     }
  227. }