src/Entity/Account.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AccountRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Doctrine\DBAL\Types\Types;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. #[ORM\Entity(repositoryClassAccountRepository::class)]
  10. #[UniqueEntity(
  11.     fields: ['email'],
  12.     message'Ya existe una cuenta registrada con este email.'
  13. )]
  14. class Account implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length180uniquetrue)]
  21.     private $email;
  22.     #[ORM\Column(type'json')]
  23.     private $roles = [];
  24.     #[ORM\Column(type'string')]
  25.     private $password;
  26.     #[ORM\Column(type'string'length255nullabletrue)]
  27.     private $name;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private $organization;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private $position;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     private ?\DateTimeInterface $lastConnection null;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  35.     private ?\DateTimeInterface $creationDay null;
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getEmail(): ?string
  41.     {
  42.         return $this->email;
  43.     }
  44.     public function setEmail(string $email): self
  45.     {
  46.         $this->email $email;
  47.         return $this;
  48.     }
  49.     /**
  50.      * A visual identifier that represents this Account.
  51.      *
  52.      * @see UserInterface
  53.      */
  54.     public function getUserIdentifier(): string
  55.     {
  56.         return (string) $this->email;
  57.     }
  58.     /**
  59.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  60.      */
  61.     public function getUsername(): string
  62.     {
  63.         return (string) $this->email;
  64.     }
  65.     /**
  66.      * @see UserInterface
  67.      */
  68.     public function getRoles(): array
  69.     {
  70.         $roles $this->roles;
  71.         // guarantee every Account at least has ROLE_USER
  72.         $roles[] = 'ROLE_USER';
  73.         return array_unique($roles);
  74.     }
  75.     public function setRoles(array $roles): self
  76.     {
  77.         $this->roles $roles;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @see PasswordAuthenticatedUserInterface
  82.      */
  83.     public function getPassword(): string
  84.     {
  85.         return $this->password;
  86.     }
  87.     public function setPassword(string $password): self
  88.     {
  89.         $this->password $password;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Returning a salt is only needed, if you are not using a modern
  94.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  95.      *
  96.      * @see UserInterface
  97.      */
  98.     public function getSalt(): ?string
  99.     {
  100.         return null;
  101.     }
  102.     /**
  103.      * @see UserInterface
  104.      */
  105.     public function eraseCredentials()
  106.     {
  107.         // If you store any temporary, sensitive data on the Account, clear it here
  108.         // $this->plainPassword = null;
  109.     }
  110.     public function getName(): ?string
  111.     {
  112.         return $this->name;
  113.     }
  114.     public function setName(?string $name): self
  115.     {
  116.         $this->name $name;
  117.         return $this;
  118.     }
  119.     public function getOrganization(): ?string
  120.     {
  121.         return $this->organization;
  122.     }
  123.     public function setOrganization(?string $organization): self
  124.     {
  125.         $this->organization $organization;
  126.         return $this;
  127.     }
  128.     public function getPosition(): ?string
  129.     {
  130.         return $this->position;
  131.     }
  132.     public function setPosition(?string $position): self
  133.     {
  134.         $this->position $position;
  135.         return $this;
  136.     }
  137.     public function getLastConnection(): ?\DateTimeInterface
  138.     {
  139.         return $this->lastConnection;
  140.     }
  141.     public function setLastConnection(?\DateTimeInterface $lastConnection): static
  142.     {
  143.         $this->lastConnection $lastConnection;
  144.         return $this;
  145.     }
  146.     public function getCreationDay(): ?\DateTimeInterface
  147.     {
  148.         return $this->creationDay;
  149.     }
  150.     public function setCreationDay(?\DateTimeInterface $creationDay): static
  151.     {
  152.         $this->creationDay $creationDay;
  153.         return $this;
  154.     }
  155. }