src/Entity/User.php line 14

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserRepository::class)
  9.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  10.  */
  11. class User implements UserInterface
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=180, unique=true)
  21.      */
  22.     private $email;
  23.     /**
  24.      * @ORM\Column(type="json")
  25.      */
  26.     private $roles = [];
  27.     /**
  28.      * @var string The hashed password
  29.      * @ORM\Column(type="string")
  30.      */
  31.     private $password;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $firstName;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      */
  39.     private $lastName;
  40.     /**
  41.      * @ORM\Column(type="boolean")
  42.      */
  43.     private $isVerified false;
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getEmail(): ?string
  49.     {
  50.         return $this->email;
  51.     }
  52.     public function setEmail(string $email): self
  53.     {
  54.         $this->email $email;
  55.         return $this;
  56.     }
  57.     /**
  58.      * A visual identifier that represents this user.
  59.      *
  60.      * @see UserInterface
  61.      */
  62.     public function getUsername(): string
  63.     {
  64.         return (string) $this->email;
  65.     }
  66.     /**
  67.      * @see UserInterface
  68.      */
  69.     public function getRoles(): array
  70.     {
  71.         $roles $this->roles;
  72.         return array_unique($roles);
  73.     }
  74.     public function setRoles(array $roles): self
  75.     {
  76.         $this->roles $roles;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @see UserInterface
  81.      */
  82.     public function getPassword(): string
  83.     {
  84.         return (string) $this->password;
  85.     }
  86.     public function setPassword(string $password): self
  87.     {
  88.         $this->password $password;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @see UserInterface
  93.      */
  94.     public function getSalt()
  95.     {
  96.         // not needed when using the "bcrypt" algorithm in security.yaml
  97.     }
  98.     /**
  99.      * @see UserInterface
  100.      */
  101.     public function eraseCredentials()
  102.     {
  103.         // If you store any temporary, sensitive data on the user, clear it here
  104.         // $this->plainPassword = null;
  105.     }
  106.     public function getFirstName(): ?string
  107.     {
  108.         return $this->firstName;
  109.     }
  110.     public function setFirstName(string $firstName): self
  111.     {
  112.         $this->firstName $firstName;
  113.         return $this;
  114.     }
  115.     public function getLastName(): ?string
  116.     {
  117.         return $this->lastName;
  118.     }
  119.     public function setLastName(string $lastName): self
  120.     {
  121.         $this->lastName $lastName;
  122.         return $this;
  123.     }
  124.     public function isVerified(): bool
  125.     {
  126.         return $this->isVerified;
  127.     }
  128.     public function setIsVerified(bool $isVerified): self
  129.     {
  130.         $this->isVerified $isVerified;
  131.         return $this;
  132.     }
  133. }