src/Entity/User.php line 13

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