src/Entity/Users.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsersRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. #[ORM\Entity(repositoryClassUsersRepository::class)]
  9. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  10. class Users implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180uniquetrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column]
  19.     private array $roles = [];
  20.     /**
  21.      * @var string The hashed password
  22.      */
  23.     #[ORM\Column]
  24.     private ?string $password null;
  25.     #[ORM\Column(length255)]
  26.     private ?string $firstname null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $lastname null;
  29.     #[ORM\Column(length255)]
  30.     private ?string $city null;
  31.     #[ORM\Column]
  32.     private ?int $phone null;
  33.     #[ORM\Column(type'boolean')]
  34.     private $isVerified false;
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getEmail(): ?string
  40.     {
  41.         return $this->email;
  42.     }
  43.     public function setEmail(string $email): self
  44.     {
  45.         $this->email $email;
  46.         return $this;
  47.     }
  48.     /**
  49.      * A visual identifier that represents this user.
  50.      *
  51.      * @see UserInterface
  52.      */
  53.     public function getUserIdentifier(): string
  54.     {
  55.         return (string) $this->email;
  56.     }
  57.     /**
  58.      * @see UserInterface
  59.      */
  60.     public function getRoles(): array
  61.     {
  62.         $roles $this->roles;
  63.         // guarantee every user at least has ROLE_USER
  64.         $roles[] = 'ROLE_USER';
  65.         return array_unique($roles);
  66.     }
  67.     public function setRoles(array $roles): self
  68.     {
  69.         $this->roles $roles;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @see PasswordAuthenticatedUserInterface
  74.      */
  75.     public function getPassword(): string
  76.     {
  77.         return $this->password;
  78.     }
  79.     public function setPassword(string $password): self
  80.     {
  81.         $this->password $password;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @see UserInterface
  86.      */
  87.     public function eraseCredentials()
  88.     {
  89.         // If you store any temporary, sensitive data on the user, clear it here
  90.         // $this->plainPassword = null;
  91.     }
  92.     public function getFirstname(): ?string
  93.     {
  94.         return $this->firstname;
  95.     }
  96.     public function setFirstname(string $firstname): self
  97.     {
  98.         $this->firstname $firstname;
  99.         return $this;
  100.     }
  101.     public function getLastname(): ?string
  102.     {
  103.         return $this->lastname;
  104.     }
  105.     public function setLastname(string $lastname): self
  106.     {
  107.         $this->lastname $lastname;
  108.         return $this;
  109.     }
  110.     public function getCity(): ?string
  111.     {
  112.         return $this->city;
  113.     }
  114.     public function setCity(string $city): self
  115.     {
  116.         $this->city $city;
  117.         return $this;
  118.     }
  119.     public function getPhone(): ?int
  120.     {
  121.         return $this->phone;
  122.     }
  123.     public function setPhone(int $phone): self
  124.     {
  125.         $this->phone $phone;
  126.         return $this;
  127.     }
  128.     public function isVerified(): bool
  129.     {
  130.         return $this->isVerified;
  131.     }
  132.     public function setIsVerified(bool $isVerified): self
  133.     {
  134.         $this->isVerified $isVerified;
  135.         return $this;
  136.     }
  137.     public function isIsVerified(): ?bool
  138.     {
  139.         return $this->isVerified;
  140.     }
  141. }