<?php
namespace App\Entity;
use App\Repository\UsersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
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: UsersRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'Cette adresse mail est déjà utilisé')]
class Users implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private int $id;
#[ORM\Column(length: 20, unique: true)]
private string $email;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column(length: 255)]
private ?string $password = null;
// #[ORM\Column(length: 200)]
// private ?string $pseudo = null;
#[ORM\Column(length: 100, nullable: true)]
private ?string $contact;
#[ORM\Column(length: 20)]
private ?string $fonction;
#[ORM\Column(length: 20)]
private ?string $nom;
#[ORM\Column(length: 10, nullable: true)]
private ?string $statut;
#[ORM\Column(length: 200, nullable: true)]
private ?string $image = 'NO_FILE';
#[ORM\Column(length: 100, nullable: true)]
private string $role;
#[ORM\Column]
private ?\DateTimeImmutable $created_at = null;
private ?string $plainpassword = null;
public function __construct(){
$this->created_at = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): static
{
$this->nom = $nom;
return $this;
}
public function setPlainPassword(string $plainpassword): static
{
$this->plainpassword = $plainpassword;
return $this;
}
public function getPlainPassword(): ?string
{
return $this->plainpassword;
}
/**
* 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;
// guarantee every user at least has ROLE
$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(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getFonction(): ?string
{
return $this->fonction;
}
public function setFonction(string $fonction): static
{
$this->fonction = $fonction;
return $this;
}
public function getRole(): ?string
{
return $this->role;
// $role[] = 'USER, ADMIN';
//return array_unique($role);
}
public function setRole(string $role): static
{
$this->role = $role;
return $this;
}
public function getContact(): ?string
{
return $this->contact;
}
public function setContact(string $contact): static
{
$this->contact = $contact;
return $this;
}
public function getStatut(): ?string
{
return $this->statut;
}
public function setStatut(string $statut): static
{
$this->statut = $statut;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(string $image): static
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): static
{
$this->created_at = $created_at;
return $this;
}
}