src/Entity/User.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. #[ORM\Entity(repositoryClassUserRepository::class)]
  9. class User implements UserInterfacePasswordAuthenticatedUserInterface
  10. {
  11.     const STATUS_PENDING 0;
  12.     const STATUS_ACTIVE  1;
  13.     const STATUS_LOCKED  5;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\Column(length180)]
  28.     private ?string $firstname null;
  29.     #[ORM\Column(length180)]
  30.     private ?string $lastname null;
  31.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  32.     private ?\DateTimeInterface $last_login null;
  33.     #[ORM\Column(typeTypes::SMALLINT)]
  34.     private ?int $status null;
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getEmail(): ?string
  40.     {
  41.         return $this->email;
  42.     }
  43.     public function setEmail(string $email): self
  44.     {
  45.         $this->email $email;
  46.         return $this;
  47.     }
  48.     /**
  49.      * A visual identifier that represents this user.
  50.      *
  51.      * @see UserInterface
  52.      */
  53.     public function getUserIdentifier(): string
  54.     {
  55.         return (string) $this->email;
  56.     }
  57.     /**
  58.      * @see UserInterface
  59.      */
  60.     public function getRoles(): array
  61.     {
  62.         $roles $this->roles;
  63.         // guarantee every user at least has ROLE_USER
  64.         $roles[] = 'ROLE_USER';
  65.         return array_unique($roles);
  66.     }
  67.     public function setRoles(array $roles): self
  68.     {
  69.         $this->roles $roles;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @see PasswordAuthenticatedUserInterface
  74.      */
  75.     public function getPassword(): string
  76.     {
  77.         return $this->password;
  78.     }
  79.     public function setPassword(string $password): self
  80.     {
  81.         $this->password $password;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @see UserInterface
  86.      */
  87.     public function eraseCredentials()
  88.     {
  89.         // If you store any temporary, sensitive data on the user, clear it here
  90.         // $this->plainPassword = null;
  91.     }
  92.     public function getFirstname(): ?string
  93.     {
  94.         return $this->firstname;
  95.     }
  96.     public function setFirstname(string $firstname): self
  97.     {
  98.         $this->firstname $firstname;
  99.         return $this;
  100.     }
  101.     public function getLastname(): ?string
  102.     {
  103.         return $this->lastname;
  104.     }
  105.     public function setLastname(string $lastname): self
  106.     {
  107.         $this->lastname $lastname;
  108.         return $this;
  109.     }
  110.     public function getLastLogin(): ?\DateTimeInterface
  111.     {
  112.         return $this->last_login;
  113.     }
  114.     public function setLastLogin(?\DateTimeInterface $last_login): self
  115.     {
  116.         $this->last_login $last_login;
  117.         return $this;
  118.     }
  119.     public function getStatus(): ?int
  120.     {
  121.         return $this->status;
  122.     }
  123.     public function setStatus(int $status): self
  124.     {
  125.         $this->status $status;
  126.         return $this;
  127.     }
  128. }