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