src/Entity/User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. #[UniqueEntity(fields: ['email'], message'Il existe déjà un compte avec cet email')]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length180uniquetrue)]
  18.     private ?string $email null;
  19.     #[ORM\Column]
  20.     private array $roles = [];
  21.     /**
  22.      * @var string The hashed password
  23.      */
  24.     #[ORM\Column]
  25.     private ?string $password null;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     private ?string $lastname null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $firstname null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?int $phone null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?int $blocked_statut null;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  35.     private ?\DateTimeInterface $last_login null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $password_reset null;
  38.     #[ORM\Column(length255nullabletrue)]
  39.     private ?string $accept_cgu null;
  40.     #[ORM\Column(length255nullabletrue)]
  41.     private ?string $entreprise null;
  42.     #[ORM\Column(type'string'length100uniquetruenullabletrue)]
  43.     private $resetToken null;
  44.     #[ORM\Column(type'boolean')]
  45.     private $is_verified false;
  46.     // #[ORM\ManyToOne(inversedBy: 'users')]
  47.     // #[ORM\JoinColumn(nullable: false)]
  48.     // private ?Roles $role = null;
  49.     // *********************** GETTER/SETTER  **************************************************
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getEmail(): ?string
  55.     {
  56.         return $this->email;
  57.     }
  58.     public function setEmail(string $email): self
  59.     {
  60.         $this->email $email;
  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->email;
  71.     }
  72.     /**
  73.      * @see UserInterface
  74.      */
  75.     public function getRoles(): array
  76.     {
  77.         $roles $this->roles;
  78.         //on garantie que chaque utilisateur a au moins le  "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.      * @see UserInterface
  101.      */
  102.     public function eraseCredentials()
  103.     {
  104.         // If you store any temporary, sensitive data on the user, clear it here
  105.         // $this->plainPassword = null;
  106.     }
  107.     public function getLastname(): ?string
  108.     {
  109.         return $this->lastname;
  110.     }
  111.     public function setLastname(?string $lastname): self
  112.     {
  113.         $this->lastname $lastname;
  114.         return $this;
  115.     }
  116.     public function getFirstname(): ?string
  117.     {
  118.         return $this->firstname;
  119.     }
  120.     public function setFirstname(?string $firstname): self
  121.     {
  122.         $this->firstname $firstname;
  123.         return $this;
  124.     }
  125.     public function getPhone(): ?int
  126.     {
  127.         return $this->phone;
  128.     }
  129.     public function setPhone(?int $phone): self
  130.     {
  131.         $this->phone $phone;
  132.         return $this;
  133.     }
  134.     public function getBlockedStatut(): ?int
  135.     {
  136.         return $this->blocked_statut;
  137.     }
  138.     public function setBlockedStatut(?int $blocked_statut): self
  139.     {
  140.         $this->blocked_statut $blocked_statut;
  141.         return $this;
  142.     }
  143.     public function getLastLogin(): ?\DateTimeInterface
  144.     {
  145.         return $this->last_login;
  146.     }
  147.     public function setLastLogin(?\DateTimeInterface $last_login): self
  148.     {
  149.         $this->last_login $last_login;
  150.         return $this;
  151.     }
  152.     public function getPasswordReset(): ?int
  153.     {
  154.         return $this->password_reset;
  155.     }
  156.     public function setPasswordReset(?int $password_reset): self
  157.     {
  158.         $this->password_reset $password_reset;
  159.         return $this;
  160.     }
  161.     public function getAcceptCgu(): ?string
  162.     {
  163.         return $this->accept_cgu;
  164.     }
  165.     public function setAcceptCgu(?string $accept_cgu): self
  166.     {
  167.         $this->accept_cgu $accept_cgu;
  168.         return $this;
  169.     }
  170.     public function getEntreprise(): ?string
  171.     {
  172.         return $this->entreprise;
  173.     }
  174.     public function setEntreprise(?string $entreprise): self
  175.     {
  176.         $this->entreprise $entreprise;
  177.         return $this;
  178.     }
  179.     public function getResetToken(): ?string
  180.     {
  181.         return $this->resetToken;
  182.     }
  183.     public function setResetToken(?string $resetToken): self
  184.     {
  185.         $this->resetToken $resetToken;
  186.         return $this;
  187.     }
  188.     public function getIsVerified(): ?bool
  189.     {
  190.         return $this->is_verified;
  191.     }
  192.     public function setIsVerified(Bool $is_verified): self
  193.     {
  194.         $this->is_verified $is_verified;
  195.         return $this;
  196.     }
  197.     // public function getRole(): ?Roles
  198.     // {
  199.     //     return $this->role;
  200.     // }
  201.     // public function setRole(?Roles $role): self
  202.     // {
  203.     //     $this->role = $role;
  204.     //     return $this;
  205.     // }
  206. }