<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'Il existe déjà un compte avec cet email')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $lastname = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $firstname = null;
#[ORM\Column(nullable: true)]
private ?int $phone = null;
#[ORM\Column(nullable: true)]
private ?int $blocked_statut = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $last_login = null;
#[ORM\Column(nullable: true)]
private ?int $password_reset = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $accept_cgu = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $entreprise = null;
#[ORM\Column(type: 'string', length: 100, unique: true, nullable: true)]
private $resetToken = null;
#[ORM\Column(type: 'boolean')]
private $is_verified = false;
// #[ORM\ManyToOne(inversedBy: 'users')]
// #[ORM\JoinColumn(nullable: false)]
// private ?Roles $role = null;
// *********************** GETTER/SETTER **************************************************
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
//on garantie que chaque utilisateur a au moins le "ROLE_USER"
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getPhone(): ?int
{
return $this->phone;
}
public function setPhone(?int $phone): self
{
$this->phone = $phone;
return $this;
}
public function getBlockedStatut(): ?int
{
return $this->blocked_statut;
}
public function setBlockedStatut(?int $blocked_statut): self
{
$this->blocked_statut = $blocked_statut;
return $this;
}
public function getLastLogin(): ?\DateTimeInterface
{
return $this->last_login;
}
public function setLastLogin(?\DateTimeInterface $last_login): self
{
$this->last_login = $last_login;
return $this;
}
public function getPasswordReset(): ?int
{
return $this->password_reset;
}
public function setPasswordReset(?int $password_reset): self
{
$this->password_reset = $password_reset;
return $this;
}
public function getAcceptCgu(): ?string
{
return $this->accept_cgu;
}
public function setAcceptCgu(?string $accept_cgu): self
{
$this->accept_cgu = $accept_cgu;
return $this;
}
public function getEntreprise(): ?string
{
return $this->entreprise;
}
public function setEntreprise(?string $entreprise): self
{
$this->entreprise = $entreprise;
return $this;
}
public function getResetToken(): ?string
{
return $this->resetToken;
}
public function setResetToken(?string $resetToken): self
{
$this->resetToken = $resetToken;
return $this;
}
public function getIsVerified(): ?bool
{
return $this->is_verified;
}
public function setIsVerified(Bool $is_verified): self
{
$this->is_verified = $is_verified;
return $this;
}
// public function getRole(): ?Roles
// {
// return $this->role;
// }
// public function setRole(?Roles $role): self
// {
// $this->role = $role;
// return $this;
// }
}