src/Entity/Main/User.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Main;
  3. use App\Repository\Main\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. /**
  8.  * @ORM\Entity(repositoryClass=UserRepository::class)
  9.  */
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=180, unique=true)
  20.      */
  21.     private $username;
  22.     /**
  23.      * @ORM\Column(type="json")
  24.      */
  25.     private $roles = [];
  26.     /**
  27.      * @var string The hashed password
  28.      * @ORM\Column(type="string")
  29.      */
  30.     private $password;
  31.     /**
  32.      * @ORM\Column(type="string", length=180)
  33.      */
  34.     private $email;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $prenom;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $nom;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $is_active;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      */
  50.     private $last_login;
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     /**
  56.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  57.      */
  58.     public function getUsername(): string
  59.     {
  60.         return (string) $this->username;
  61.     }
  62.     public function setUsername(string $username): self
  63.     {
  64.         $this->username $username;
  65.         return $this;
  66.     }
  67.     /**
  68.      * A visual identifier that represents this user.
  69.      *
  70.      * @see UserInterface
  71.      */
  72.     public function getUserIdentifier(): string
  73.     {
  74.         return (string) $this->username;
  75.     }
  76.     /**
  77.      * @see UserInterface
  78.      */
  79.     public function getRoles(): array
  80.     {
  81.         $roles $this->roles;
  82.         // guarantee every user at least has ROLE_USER
  83.         $roles[] = 'ROLE_USER';
  84.         return array_unique($roles);
  85.     }
  86.     public function setRoles(array $roles): self
  87.     {
  88.         $this->roles $roles;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @see PasswordAuthenticatedUserInterface
  93.      */
  94.     public function getPassword(): string
  95.     {
  96.         return $this->password;
  97.     }
  98.     public function setPassword(string $password): self
  99.     {
  100.         $this->password $password;
  101.         return $this;
  102.     }
  103.     /**
  104.      * Returning a salt is only needed, if you are not using a modern
  105.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  106.      *
  107.      * @see UserInterface
  108.      */
  109.     public function getSalt(): ?string
  110.     {
  111.         return null;
  112.     }
  113.     /**
  114.      * @see UserInterface
  115.      */
  116.     public function eraseCredentials()
  117.     {
  118.         // If you store any temporary, sensitive data on the user, clear it here
  119.         // $this->plainPassword = null;
  120.     }
  121.     public function getEmail(): ?string
  122.     {
  123.         return $this->email;
  124.     }
  125.     public function setEmail(string $email): self
  126.     {
  127.         $this->email $email;
  128.         return $this;
  129.     }
  130.     public function getPrenom(): ?string
  131.     {
  132.         return $this->prenom;
  133.     }
  134.     public function setPrenom(string $prenom): self
  135.     {
  136.         $this->prenom $prenom;
  137.         return $this;
  138.     }
  139.     public function getNom(): ?string
  140.     {
  141.         return $this->nom;
  142.     }
  143.     public function setNom(string $nom): self
  144.     {
  145.         $this->nom $nom;
  146.         return $this;
  147.     }
  148.     public function isActive(): bool
  149.     {
  150.         return $this->is_active;
  151.     }
  152.     public function setIsActive(bool $is_active): self
  153.     {
  154.         $this->is_active $is_active;
  155.         return $this;
  156.     }
  157.     public function getLastLogin(): ?\DateTimeInterface
  158.     {
  159.         return $this->last_login;
  160.     }
  161.     public function setLastLogin(?\DateTimeInterface $last_login): self
  162.     {
  163.         $this->last_login $last_login;
  164.         return $this;
  165.     }
  166. }