src/Entity/User.php line 16

  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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[ORM\UniqueConstraint(name'UNIQ_IDENTIFIER_EMAIL'fields: ['email'])]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180)]
  20.     private ?string $email null;
  21.     /**
  22.      * @var string[] The user roles
  23.      */
  24.     #[ORM\Column(type'array')]
  25.     private array $roles = [];
  26.     /**
  27.      * @var string The hashed password
  28.      */
  29.     #[ORM\Column]
  30.     private ?string $password null;
  31.     #[ORM\OneToMany(targetEntityDocumento::class, mappedBy'user')]
  32.     private Collection $documentos;
  33.     #[ORM\ManyToMany(targetEntityCliente::class, inversedBy'users')]
  34.     #[ORM\JoinTable(name'users_clientes')]
  35.     private Collection $clientes;
  36.    
  37.     #[ORM\Column(length255)]
  38.     private ?string $nome null;
  39.     #[ORM\Column(nullabletrue)]
  40.     private ?array $tipoAcesso null;
  41.     #[ORM\OneToMany(mappedBy'user'targetEntityFluxo::class)]
  42.     private Collection $fluxos;
  43.     #[ORM\OneToMany(mappedBy'user'targetEntityEtapa::class)]
  44.     private Collection $etapas;
  45.     #[ORM\Column]
  46.     private ?bool $enabled null;
  47.     public function __construct()
  48.     {
  49.         $this->documentos = new ArrayCollection();
  50.         $this->logs = new ArrayCollection();
  51.         $this->clientes = new ArrayCollection();
  52.         $this->registros = new ArrayCollection();
  53.         $this->fluxos = new ArrayCollection();
  54.         $this->etapas = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getEmail(): ?string
  61.     {
  62.         return $this->email;
  63.     }
  64.     public function setEmail(string $email): static
  65.     {
  66.         $this->email $email;
  67.         return $this;
  68.     }
  69.     /**
  70.      * A visual identifier that represents this user.
  71.      *
  72.      * @see UserInterface
  73.      */
  74.     public function getUserIdentifier(): string
  75.     {
  76.         return (string) $this->email;
  77.     }
  78.     /**
  79.      * @see UserInterface
  80.      *
  81.      * @return list<string>
  82.      */
  83.     public function getRoles(): array
  84.     {
  85.         $roles $this->roles;
  86.         // guarantee every user at least has ROLE_USER
  87.         $roles[] = 'ROLE_USER';
  88.         return array_unique($roles);
  89.     }
  90.     /**
  91.      * @param list<string> $roles
  92.      */
  93.     public function setRoles(array $roles): static
  94.     {
  95.         $this->roles $roles;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @see PasswordAuthenticatedUserInterface
  100.      */
  101.     public function getPassword(): string
  102.     {
  103.         return $this->password;
  104.     }
  105.     public function setPassword(string $password): static
  106.     {
  107.         $this->password $password;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     public function eraseCredentials(): void
  114.     {
  115.         // If you store any temporary, sensitive data on the user, clear it here
  116.         // $this->plainPassword = null;
  117.     }
  118.     /**
  119.      * @return Collection<int, Documento>
  120.      */
  121.     public function getDocumentos(): Collection
  122.     {
  123.         return $this->documentos;
  124.     }
  125.     public function addDocumento(Documento $documento): static
  126.     {
  127.         if (!$this->documentos->contains($documento)) {
  128.             $this->documentos->add($documento);
  129.             $documento->setUser($this);
  130.         }
  131.         return $this;
  132.     }
  133.     public function removeDocumento(Documento $documento): static
  134.     {
  135.         if ($this->documentos->removeElement($documento)) {
  136.             // set the owning side to null (unless already changed)
  137.             if ($documento->getUser() === $this) {
  138.                 $documento->setUser(null);
  139.             }
  140.         }
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Collection<int, Cliente>
  145.      */
  146.     public function getClientes(): Collection
  147.     {
  148.         return $this->clientes;
  149.     }
  150.     public function addCliente(Cliente $cliente): static
  151.     {
  152.         if (!$this->clientes->contains($cliente)) {
  153.             $this->clientes->add($cliente);
  154.             $cliente->addUser($this);
  155.         }
  156.         return $this;
  157.     }
  158.     public function removeCliente(Cliente $cliente): static
  159.     {
  160.         if ($this->clientes->removeElement($cliente)) {
  161.             $cliente->removeUser($this);
  162.         }
  163.         return $this;
  164.     }
  165.   
  166.     public function getNome(): ?string
  167.     {
  168.         return $this->nome;
  169.     }
  170.     public function setNome(string $nome): static
  171.     {
  172.         $this->nome $nome;
  173.         return $this;
  174.     }
  175.     public function getTipoAcesso(): ?array
  176.     {
  177.         return $this->tipoAcesso;
  178.     }
  179.     public function setTipoAcesso(?array $tipoAcesso): static
  180.     {
  181.         $this->tipoAcesso $tipoAcesso;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, Fluxo>
  186.      */
  187.     public function getFluxos(): Collection
  188.     {
  189.         return $this->fluxos;
  190.     }
  191.     public function addFluxo(Fluxo $fluxo): static
  192.     {
  193.         if (!$this->fluxos->contains($fluxo)) {
  194.             $this->fluxos->add($fluxo);
  195.             $fluxo->setUser($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeFluxo(Fluxo $fluxo): static
  200.     {
  201.         if ($this->fluxos->removeElement($fluxo)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($fluxo->getUser() === $this) {
  204.                 $fluxo->setUser(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Etapa>
  211.      */
  212.     public function getEtapas(): Collection
  213.     {
  214.         return $this->etapas;
  215.     }
  216.     public function addEtapa(Etapa $etapa): static
  217.     {
  218.         if (!$this->etapas->contains($etapa)) {
  219.             $this->etapas->add($etapa);
  220.             $etapa->setUser($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeEtapa(Etapa $etapa): static
  225.     {
  226.         if ($this->etapas->removeElement($etapa)) {
  227.             // set the owning side to null (unless already changed)
  228.             if ($etapa->getUser() === $this) {
  229.                 $etapa->setUser(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234.     public function isEnabled(): ?bool
  235.     {
  236.         return $this->enabled;
  237.     }
  238.     public function setEnabled(bool $enabled): static
  239.     {
  240.         $this->enabled $enabled;
  241.         return $this;
  242.     }
  243. }