src\Entity\User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. #[ORM\Table(name'`user`')]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     const SOLICITANTE 'ROLE_SOLICITANTE';
  14.     const APROVADOR 'ROLE_APROVADOR';
  15.     const SUPER_USUARIO 'ROLE_SUPER';
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length180uniquetrue)]
  21.     private ?string $username null;
  22.     #[ORM\Column(length180uniquetrue)]
  23.     private ?string $nome null;
  24.     #[ORM\Column(length180nullabletrueuniquetrue)]
  25.     private ?string $email null;
  26.     #[ORM\Column(type'json')]
  27.     private array $roles = [];
  28.     /**
  29.      * @var string The hashed password
  30.      */
  31.     #[ORM\Column]
  32.     private ?string $password null;
  33.     #[ORM\Column]
  34.     private ?\DateTimeImmutable $createdAt null;
  35.     #[ORM\OneToMany(mappedBy'usuario'targetEntitySolicitacao::class)]
  36.     private Collection $solicitacaos;
  37.     #[ORM\OneToMany(mappedBy'aprovador'targetEntitySolicitacao::class)]
  38.     private Collection $aprovador;
  39.     #[ORM\OneToMany(mappedBy'administrador'targetEntitySolicitacao::class)]
  40.     private Collection $administrador;
  41.     #[ORM\OneToMany(mappedBy'recusador'targetEntitySolicitacao::class)]
  42.     private Collection $recusador;
  43.     #[ORM\Column]
  44.     private ?bool $isActive;
  45.     #[ORM\Column(nullablefalse)]
  46.     private ?bool $notificacaoEmailAceito;
  47.     #[ORM\Column(nullablefalse)]
  48.     private ?bool $notificacaoEmailRecusado;
  49.     #[ORM\Column(nullablefalse)]
  50.     private ?bool $notificacaoEmailNovaSolicitacao;
  51.     #[ORM\ManyToMany(targetEntityEmpresa::class, mappedBy'users')]
  52.     private Collection $empresas;
  53.     #[ORM\ManyToMany(targetEntitySubEmpresa::class, mappedBy'users')]
  54.     private Collection $subEmpresas;
  55.     public function __construct()
  56.     {
  57.         $this->createdAt = new \DateTimeImmutable('now');
  58.         $this->isActive true;
  59.         $this->notificacaoEmailRecusado false;
  60.         $this->notificacaoEmailNovaSolicitacao false;
  61.         $this->notificacaoEmailAceito false;
  62.         $this->solicitacaos = new ArrayCollection();
  63.         $this->aprovador = new ArrayCollection();
  64.         $this->administrador = new ArrayCollection();
  65.         $this->recusador = new ArrayCollection();
  66.         $this->empresas = new ArrayCollection();
  67.         $this->subEmpresas = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getUsername(): ?string
  74.     {
  75.         return $this->username;
  76.     }
  77.     public function setUsername(string $username): self
  78.     {
  79.         $this->username $username;
  80.         return $this;
  81.     }
  82.     /**
  83.      * A visual identifier that represents this user.
  84.      *
  85.      * @see UserInterface
  86.      */
  87.     public function getUserIdentifier(): string
  88.     {
  89.         return (string) $this->username;
  90.     }
  91.     /**
  92.      * @see UserInterface
  93.      */
  94.     public function getRoles(): array
  95.     {
  96.         $roles $this->roles;
  97.         // guarantee every user at least has ROLE_USER
  98.         // $roles[] = 'ROLE_USER';
  99.         return array_unique($roles);
  100.     }
  101.     public function setRoles(array $roles): self
  102.     {
  103.         $this->roles $roles;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @see PasswordAuthenticatedUserInterface
  108.      */
  109.     public function getPassword(): string
  110.     {
  111.         return $this->password;
  112.     }
  113.     public function setPassword(string $password): self
  114.     {
  115.         $this->password $password;
  116.         return $this;
  117.     }
  118.     /**
  119.      * @see UserInterface
  120.      */
  121.     public function eraseCredentials()
  122.     {
  123.         // If you store any temporary, sensitive data on the user, clear it here
  124.         // $this->plainPassword = null;
  125.     }
  126.     public function isEnabled()
  127.     {
  128.         return $this->isActive;
  129.     }
  130.     public function getNome(): ?string
  131.     {
  132.         return $this->nome;
  133.     }
  134.     public function setNome(string $nome): self
  135.     {
  136.         $this->nome $nome;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, Solicitacao>
  141.      */
  142.     public function getSolicitacaos(): Collection
  143.     {
  144.         return $this->solicitacaos;
  145.     }
  146.     public function addSolicitacao(Solicitacao $solicitacao): self
  147.     {
  148.         if (!$this->solicitacaos->contains($solicitacao)) {
  149.             $this->solicitacaos->add($solicitacao);
  150.             $solicitacao->setUsuario($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeSolicitacao(Solicitacao $solicitacao): self
  155.     {
  156.         if ($this->solicitacaos->removeElement($solicitacao)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($solicitacao->getUsuario() === $this) {
  159.                 $solicitacao->setUsuario(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164.     public function getCreatedAt(): ?\DateTimeImmutable
  165.     {
  166.         return $this->createdAt;
  167.     }
  168.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  169.     {
  170.         $this->createdAt $createdAt;
  171.         return $this;
  172.     }
  173.     public function isIsActive(): ?bool
  174.     {
  175.         return $this->isActive;
  176.     }
  177.     public function setIsActive(bool $isActive): self
  178.     {
  179.         $this->isActive $isActive;
  180.         return $this;
  181.     }
  182.     /**
  183.      * @return Collection<int, Solicitacao>
  184.      */
  185.     public function getAprovador(): Collection
  186.     {
  187.         return $this->aprovador;
  188.     }
  189.     public function addAprovador(Solicitacao $aprovador): self
  190.     {
  191.         if (!$this->aprovador->contains($aprovador)) {
  192.             $this->aprovador->add($aprovador);
  193.             $aprovador->setAprovador($this);
  194.         }
  195.         return $this;
  196.     }
  197.     public function removeAprovador(Solicitacao $aprovador): self
  198.     {
  199.         if ($this->aprovador->removeElement($aprovador)) {
  200.             // set the owning side to null (unless already changed)
  201.             if ($aprovador->getAprovador() === $this) {
  202.                 $aprovador->setAprovador(null);
  203.             }
  204.         }
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return Collection<int, Solicitacao>
  209.      */
  210.     public function getAdministrador(): Collection
  211.     {
  212.         return $this->administrador;
  213.     }
  214.     public function addAdministrador(Solicitacao $administrador): self
  215.     {
  216.         if (!$this->administrador->contains($administrador)) {
  217.             $this->administrador->add($administrador);
  218.             $administrador->setAdministrador($this);
  219.         }
  220.         return $this;
  221.     }
  222.     public function removeAdministrador(Solicitacao $administrador): self
  223.     {
  224.         if ($this->administrador->removeElement($administrador)) {
  225.             // set the owning side to null (unless already changed)
  226.             if ($administrador->getAdministrador() === $this) {
  227.                 $administrador->setAdministrador(null);
  228.             }
  229.         }
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return Collection<int, Solicitacao>
  234.      */
  235.     public function getRecusador(): Collection
  236.     {
  237.         return $this->recusador;
  238.     }
  239.     public function addRecusador(Solicitacao $recusador): self
  240.     {
  241.         if (!$this->recusador->contains($recusador)) {
  242.             $this->recusador->add($recusador);
  243.             $recusador->setRecusador($this);
  244.         }
  245.         return $this;
  246.     }
  247.     public function removeRecusador(Solicitacao $recusador): self
  248.     {
  249.         if ($this->recusador->removeElement($recusador)) {
  250.             // set the owning side to null (unless already changed)
  251.             if ($recusador->getRecusador() === $this) {
  252.                 $recusador->setRecusador(null);
  253.             }
  254.         }
  255.         return $this;
  256.     }
  257.     public function getEmail(): ?string
  258.     {
  259.         return $this->email;
  260.     }
  261.     public function setEmail(?string $email): self
  262.     {
  263.         $this->email $email;
  264.         return $this;
  265.     }
  266.     public function isNotificacaoEmailAceito(): ?bool
  267.     {
  268.         return $this->notificacaoEmailAceito;
  269.     }
  270.     public function setNotificacaoEmailAceito(bool $notificacaoEmailAceito): self
  271.     {
  272.         $this->notificacaoEmailAceito $notificacaoEmailAceito;
  273.         return $this;
  274.     }
  275.     public function isNotificacaoEmailRecusado(): ?bool
  276.     {
  277.         return $this->notificacaoEmailRecusado;
  278.     }
  279.     public function setNotificacaoEmailRecusado(bool $notificacaoEmailRecusado): self
  280.     {
  281.         $this->notificacaoEmailRecusado $notificacaoEmailRecusado;
  282.         return $this;
  283.     }
  284.     public function isNotificacaoEmailNovaSolicitacao(): ?bool
  285.     {
  286.         return $this->notificacaoEmailNovaSolicitacao;
  287.     }
  288.     public function setNotificacaoEmailNovaSolicitacao(bool $notificacaoEmailNovaSolicitacao): self
  289.     {
  290.         $this->notificacaoEmailNovaSolicitacao $notificacaoEmailNovaSolicitacao;
  291.         return $this;
  292.     }
  293.     /**
  294.      * @return Collection<int, Empresa>
  295.      */
  296.     public function getEmpresas(): Collection
  297.     {
  298.         return $this->empresas;
  299.     }
  300.     public function addEmpresa(Empresa $empresa): self
  301.     {
  302.         if (!$this->empresas->contains($empresa)) {
  303.             $this->empresas->add($empresa);
  304.             $empresa->addUser($this);
  305.         }
  306.         return $this;
  307.     }
  308.     public function removeEmpresa(Empresa $empresa): self
  309.     {
  310.         if ($this->empresas->removeElement($empresa)) {
  311.             $empresa->removeUser($this);
  312.         }
  313.         return $this;
  314.     }
  315.     /**
  316.      * @return Collection<int, SubEmpresa>
  317.      */
  318.     public function getSubEmpresas(): Collection
  319.     {
  320.         return $this->subEmpresas;
  321.     }
  322.     public function addSubEmpresa(SubEmpresa $subEmpresa): self
  323.     {
  324.         if (!$this->subEmpresas->contains($subEmpresa)) {
  325.             $this->subEmpresas->add($subEmpresa);
  326.             $subEmpresa->addUser($this);
  327.         }
  328.         return $this;
  329.     }
  330.     public function removeSubEmpresa(SubEmpresa $subEmpresa): self
  331.     {
  332.         if ($this->subEmpresas->removeElement($subEmpresa)) {
  333.             $subEmpresa->removeUser($this);
  334.         }
  335.         return $this;
  336.     }
  337. }