<?php
namespace App\Entity;
use App\EntityListener\UserListener;
use Doctrine\DBAL\Types\Types;
use App\Traits\TimstampleTrait;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Doctrine\Common\Collections\Collection;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\EntityListeners([UserListener::class])]
#[ORM\Table(name: '`user`')]
#[HasLifecycleCallbacks]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use TimstampleTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(["show_event", "show_commande", "list_achatVente", "show_achatVente",
"list_animaux", "show_animal", "list_appelOffre", "show_appelOffre",
"list_bateaux", "show_bateau", "list_communiques", "show_communique", "list_emplois",
"show_emploi", "list_formations", "show_formation", "list_mariages", "show_mariage",
"list_modes", "show_mode", "list_motos", "show_moto", "list_naissances", "show_naissance", "list_objets",
"show_objet", "list_proprietes", "show_propriete", "all_alaune_abj","app_group", "immo_ci",
"list_personnels", "show_personnel", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule", "list_users", "show_user", "list_admins", "show_admin"])]
private ?int $id = null;
#[ORM\Column(length: 100, unique: true)]
#[Assert\NotBlank(message: 'veuillez entrer votre adresse email')]
#[Assert\Email(message: 'veuillez entrer une adresse email valide')]
#[Groups(["show_achatVente", "list_animaux", "show_animal", "list_appelOffre", "show_appelOffre","list_bateaux", "list_users", "show_bateau", "list_communiques", "show_communique", "list_emplois","show_emploi", "list_formations", "show_formation", "list_mariages", "show_mariage", "list_modes","show_mode", "list_motos", "show_moto", "list_naissances", "show_naissance", "app_group","list_objets", "show_objet", "show_propriete", "list_personnels", "show_personnel","list_admins", "show_admin", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule", "show_user"])]
private ?string $email = null;
#[ORM\Column]
#[Assert\NotNull()]
private array $roles = [];
#[ORM\Column(length: 180)]
#[Groups(["show_achatVente", "list_animaux", "show_animal", "list_appelOffre", "show_appelOffre",
"list_bateaux", "list_users", "show_bateau", "list_communiques", "show_communique", "list_emplois",
"show_emploi", "list_formations", "show_formation", "list_mariages", "show_mariage", "list_modes",
"show_mode", "list_motos", "show_moto", "list_naissances", "show_naissance",
"list_objets", "show_objet", "show_propriete", "list_personnels", "show_personnel","list_admins", "show_admin", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule", "show_user"])]
private ?string $username = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["show_user"])]
private ?string $adresse = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'veuillez entrer votre mot de passe')]
#[Assert\Length(min:6)]
private ?string $password = 'password';
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["show_event", "list_users", "show_commande", "show_achatVente", "show_animal", "show_appelOffre",
"show_bateau", "show_communique", "show_emploi", "show_formation", "show_mariage",
"show_mode", "show_moto", "show_naissance", "show_objet", "show_propriete", "show_personnel", "show_rencontre", "show_vehicule", "show_user"])]
private ?string $ville=null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["show_event", "list_users", "show_commande", "show_achatVente", "show_animal", "show_appelOffre",
"show_bateau", "show_communique", "show_emploi", "show_formation", "show_mariage",
"show_mode", "show_moto", "show_naissance", "show_objet", "show_propriete", "show_personnel", "show_rencontre", "show_vehicule", "show_user"])]
private ?string $pays=null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["show_event", "show_achatVente", "show_animal", "show_bateau", "show_communique",
"show_emploi", "show_formation", "show_mariage", "show_mode", "show_moto", "show_naissance", "show_objet", "show_user", "show_propriete", "show_personnel", "show_rencontre", "show_vehicule"])]
private ?string $lienFacebook;
#[ORM\Column(length: 25, nullable: true)]
private $dialCode;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["show_event", "show_achatVente", "show_animal", "show_bateau", "show_communique",
"show_emploi", "show_formation", "show_mariage", "show_mode", "show_moto", "show_naissance", "show_objet", "show_user", "show_propriete", "show_personnel", "show_rencontre", "show_vehicule"])]
private ?string $lienSiteWeb;
#[ORM\Column()]
#[Groups(["show_event", "list_users", "show_achatVente", "show_animal", "show_appelOffre", "show_bateau",
"show_communique", "show_emploi", "show_formation", "show_mariage", "show_user", "list_admins", "show_admin", "show_mode", "show_moto", "show_naissance", "show_objet", "show_propriete", "show_personnel", "show_rencontre", "show_vehicule"])]
private ?bool $actif =false;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'veuillez entrer votre nom')]
#[Assert\Length(min:2, max:50)]
#[Groups(["show_event", "show_commande", "list_achatVente", "show_achatVente",
"list_animaux", "show_animal", "list_appelOffre", "show_appelOffre", "list_bateaux", "show_bateau",
"list_communiques", "show_communique", "list_emplois", "show_emploi", "list_formations", "list_commande_ticket",
"show_formation", "list_mariages", "show_mariage", "list_modes", "show_mode", "list_motos", "show_moto", "list_users",
"list_naissances", "show_naissance", "list_objets", "show_objet","list_admins", "show_admin", "list_proprietes", "show_user", "show_propriete", "list_personnels", "show_personnel", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule"])]
private ?string $nom;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'veuillez entrer votre prénom')]
#[Assert\Length(min:2, max:50)]
#[Groups(["show_event", "show_commande", "list_achatVente", "show_achatVente", "list_users",
"list_animaux", "show_animal", "list_appelOffre", "show_appelOffre", "list_bateaux", "show_bateau",
"list_communiques", "show_communique", "list_emplois", "show_emploi", "list_formations", "list_commande_ticket",
"show_formation", "list_mariages", "show_mariage", "list_modes", "show_mode", "list_motos",
"show_moto", "list_naissances", "show_naissance", "list_objets", "list_admins", "show_admin", "show_objet", "show_user","list_proprietes", "show_propriete", "list_personnels", "show_personnel", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule"])]
private ?string $prenoms;
#[ORM\Column(length: 255)]
#[Groups(["list_users", "show_user", "list_admins", "show_admin", "all_alaune_abj", "app_group", "all_waiting", "immo_ci"])]
private ?string $nomComplet;
#[ORM\Column()]
#[Groups(["list_users"])]
private ?bool $isAdmin =null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["list_users", "show_user"])]
private ?string $typeCompte =null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'veuillez entrer votre numéro de téléphone')]
#[Groups(["show_achatVente","list_users", "show_user","show_animal", "show_appelOffre", "show_bateau", "show_communique", "show_emploi",
"show_mariage", "show_mode", "list_motos", "show_moto", "list_admins", "show_admin", "list_objets", "show_objet", "list_proprietes", "show_propriete", "list_personnels", "show_personnel", "list_rencontres", "show_rencontre", "list_vehicules", "show_vehicule", "show_event"])]
private ?string $numero;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["list_users", "show_user", "list_admins", "show_admin", "all_alaune_abj", "immo_ci"])]
private $photo;
#[ORM\OneToMany(targetEntity: UserSessions::class, mappedBy: 'user', orphanRemoval: true)]
private $userSessions;
#[ORM\Column(length: 255, nullable: true)]
private ?string $source;//abj,annonce,ticket,news,business...
#[ORM\Column(type: Types::DATETIME_MUTABLE,nullable: true)]
private ?\DateTimeInterface $passwordRequestedAt = null;
#[ORM\Column()]
private ?bool $emailVerified =false;
#[ORM\Column(length: 255, nullable: true)]
private ?string $token;
private $plainPassword;
private $newPassword;
public function __construct()
{
$this->userSessions = new ArrayCollection();
$this->emailVerified = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): static
{
$this->username = $username;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(?string $adresse): static
{
$this->adresse = $adresse;
return $this;
}
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(?string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getPays(): ?string
{
return $this->pays;
}
public function setPays(?string $pays): self
{
$this->pays = $pays;
return $this;
}
public function getLienFacebook(): ?string
{
return $this->lienFacebook;
}
public function setLienFacebook(?string $lienFacebook): self
{
$this->lienFacebook = $lienFacebook;
return $this;
}
public function getDialCode(): ?string
{
return $this->dialCode;
}
public function setDialCode(?string $dialCode): self
{
$this->dialCode = $dialCode;
return $this;
}
public function getLienSiteWeb(): ?string
{
return $this->lienSiteWeb;
}
public function setLienSiteWeb(?string $lienSiteWeb): self
{
$this->lienSiteWeb = $lienSiteWeb;
return $this;
}
public function isActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenoms(): ?string
{
return $this->prenoms;
}
public function setPrenoms(string $prenoms): self
{
$this->prenoms = $prenoms;
return $this;
}
public function getNomComplet(): ?string
{
return $this->nomComplet;
}
public function setNomComplet(string $nomComplet): self
{
$this->nomComplet = $nomComplet;
return $this;
}
public function getIsAdmin(): ?bool
{
return $this->isAdmin;
}
public function setIsAdmin(bool $isAdmin): self
{
$this->isAdmin = $isAdmin;
return $this;
}
public function getTypeCompte(): ?string
{
return $this->typeCompte;
}
public function setTypeCompte(?string $typeCompte): self
{
$this->typeCompte = $typeCompte;
return $this;
}
public function getNumero(): ?string
{
return $this->numero;
}
public function setNumero(string $numero): self
{
$this->numero = $numero;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getPasswordRequestedAt(): ?\DateTimeInterface
{
return $this->passwordRequestedAt;
}
public function setPasswordRequestedAt(?\DateTimeInterface $passwordRequestedAt): self
{
$this->passwordRequestedAt = $passwordRequestedAt;
return $this;
}
public function getEmailVerified(): ?bool
{
return $this->emailVerified;
}
public function setEmailVerified(bool $emailVerified): self
{
$this->emailVerified = $emailVerified;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
public function setPlainPassword(?string $plainPassword): self
{
$this->plainPassword = $plainPassword;
return $this;
}
public function __toString()
{
return $this->nom;
}
public function getNewPassword(): ?string
{
return $this->newPassword;
}
public function setNewPassword(?string $newPassword): self
{
$this->newPassword = $newPassword;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
public function getUserIdentifier(): string
{
return (string) $this->email;
}
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* Get the value of source
*/
public function getSource()
{
return $this->source;
}
/**
* Set the value of from
*
* @return self
*/
public function setSource($source)
{
$this->source = $source;
return $this;
}
/**
* @return Collection<int, UserSessions>
*/
public function getUserSessions(): Collection
{
return $this->userSessions;
}
public function addUserSession(UserSessions $userSession): self
{
if (!$this->userSessions->contains($userSession)) {
$this->userSessions[] = $userSession;
$userSession->setUser($this);
}
return $this;
}
public function removeUserSession(UserSessions $userSession): self
{
if ($this->userSessions->removeElement($userSession)) {
// set the owning side to null (unless already changed)
if ($userSession->getUser() === $this) {
$userSession->setUser(null);
}
}
return $this;
}
}