src/Entity/User.php line 11

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