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(length50)]
  15.     private ?string $nom null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $prenom null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $username null;
  20.     #[ORM\Column(type'string'length180uniquetrue)]
  21.     private $email;
  22.     #[ORM\Column]
  23.     private array $roles = [];
  24.     /**
  25.      * @var string|null
  26.      */
  27.     private $plainPassword;
  28.     /**
  29.      * @var string The hashed password
  30.      */
  31.     #[ORM\Column]
  32.     private ?string $password null;
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  39.      */
  40.     public function getUsername(): string
  41.     {
  42.         return (string) $this->username;
  43.     }
  44.     public function setUsername(string $username): self
  45.     {
  46.         $this->username $username;
  47.         return $this;
  48.     }
  49.     /**
  50.      * A visual identifier that represents this user.
  51.      *
  52.      * @see UserInterface
  53.      */
  54.     public function getUserIdentifier(): string
  55.     {
  56.         return (string) $this->username;
  57.     }
  58.     /**
  59.      * @see UserInterface
  60.      */
  61.     public function getRoles(): array
  62.     {
  63.         $roles $this->roles;
  64.         // guarantee every user at least has ROLE_USER
  65.         $roles[] = 'ROLE_USER';
  66.         return array_unique($roles);
  67.     }
  68.     public function setRoles(array $roles): self
  69.     {
  70.         $this->roles $roles;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @see PasswordAuthenticatedUserInterface
  75.      */
  76.     public function getPassword(): string
  77.     {
  78.         return $this->password;
  79.     }
  80.     public function setPassword(string $password): self
  81.     {
  82.         $this->password $password;
  83.         return $this;
  84.     }
  85.     /**
  86.      * Returning a salt is only needed, if you are not using a modern
  87.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  88.      *
  89.      * @see UserInterface
  90.      */
  91.     public function getSalt(): ?string
  92.     {
  93.         return null;
  94.     }
  95.     /**
  96.      * @see UserInterface
  97.      */
  98.     public function eraseCredentials()
  99.     {
  100.         // If you store any temporary, sensitive data on the user, clear it here
  101.         // $this->plainPassword = null;
  102.     }
  103.     public function getEmail(): ?string
  104.     {
  105.         return $this->email;
  106.     }
  107.     public function setEmail(string $email): self
  108.     {
  109.         $this->email $email;
  110.         return $this;
  111.     }
  112.     public function getNom(): ?string
  113.     {
  114.         return $this->nom;
  115.     }
  116.     public function setNom(?string $nom): self
  117.     {
  118.         $this->nom $nom;
  119.         return $this;
  120.     }
  121.     public function getPrenom(): ?string
  122.     {
  123.         return $this->prenom;
  124.     }
  125.     public function setPrenom(string $prenom): self
  126.     {
  127.         $this->prenom $prenom;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return string|null
  132.      */
  133.     public function getPlainPassword(): ?string
  134.     {
  135.         return $this->plainPassword;
  136.     }
  137.     /**
  138.      * @param string|null $plainPassword
  139.      */
  140.     public function setPlainPassword(?string $plainPassword): void
  141.     {
  142.         $this->plainPassword $plainPassword;
  143.     }
  144.     public function __toString()
  145.     {
  146.         return $this->getNom().' '.$this->getPrenom();
  147.     }
  148.     public function getFullName(): string
  149.     {
  150.         return $this->getNom().' '.$this->getPrenom();
  151.     }
  152. }