<?php
namespace App\Entity;
use App\Repository\AppUserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=AppUserRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class AppUser implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @Gedmo\Slug(fields={"username"})
* @ORM\Column(length=128, unique=false)
*/
private $slugUsername;
/**
* @ORM\OneToOne(targetEntity="\App\Entity\Photo", cascade={"persist", "remove"})
*/
private $avatar;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $monPropreCodePromo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $codePromoUtilise;
/**
* @ORM\Column(type="string", length=1024, nullable=true)
*/
private $pushNotificationToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $emailToken;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $tokenExpireAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $casierJudiciaire;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pieceDIdentiteRecto;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pieceDIdentiteVerso;
/**
* @ORM\Column(type="string", length=255, unique=false)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=255, nullable=true)
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="prenom", type="string", length=255, nullable=true)
*/
private $prenom;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=50, nullable=true)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="sexe", type="string", length=10, nullable=true)
*/
private $sexe;
/**
* @var string
*
* @ORM\Column(name="est_supprime", type="boolean", nullable=true)
*/
private $estSupprime;
/**
* @var string
*
* @ORM\Column(name="telephone", type="string", length=255, nullable=true)
*/
private $telephone;
/**
* @var string
*
* @ORM\Column(name="adresse", type="string", length=255, nullable=true)
*/
private $adresse;
/**
* @var string
*
* @ORM\Column(name="type_compte", type="string", length=255, nullable=true)
*/
private $typeCompte;
/**
* @var string
*
* @ORM\Column(name="nom_complet", type="string", length=255, nullable=true)
*/
private $nomComplet;
/**
* @var string
*
* @ORM\Column(name="mois", type="string", length=255, nullable=true)
*/
private $mois;
/**
* @var string
*
* @ORM\Column(name="annee", type="string", length=255, nullable=true)
*/
private $annee;
/**
* @var string
*
* @ORM\Column(name="nombre_avis", type="integer", nullable=true)
*/
private $nombreAvis;
/**
* @var string
*/
private $plainPassword;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
/**
* @var string
*
* @ORM\Column(name="qualification", type="string", length=255, nullable=true)
*/
private $qualification;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string
*
* @ORM\Column(name="disponibilite", type="string", length=225, nullable=true)
*/
private $disponibilite;
/**
* @var boolean
*
* @ORM\Column(name="enabled", type="boolean", nullable=true)
*/
private $enabled;
/**
* @var string
*
* @ORM\Column(name="gamme_de_prix", type="string", length=225, nullable=true)
*/
private $gammeDePrix;
/**
* @var string
*
* @ORM\Column(name="main_d_oeuvre", type="string", length=225, nullable=true)
*/
private $mainDOeuvre;
/**
* @var string
*
* @ORM\Column(name="zone_d_intervention", type="string", length=225, nullable=true)
*/
private $zoneDIntervention;
/**
* @var string
*
* @ORM\Column(name="domaine_d_activite", type="string", length=225, nullable=true)
*/
private $domaineDActivite;
/**
* @var string
*
* @ORM\Column(name="est_embassadeur", type="boolean", nullable=true)
*/
private $estEmbassadeur;
/**
* Constructor
*/
public function __construct()
{
$this->roles = ['ROLE_USER'];
$this->createdAt = new \DateTime('now');
$p = new Photo;
$p->setUrl('image/male-user.png');
$p->setAlt('Photo de profile');
$this->avatar = $p;
$this->mois = date('mY');
$this->annee = date('Y');
$this->nombreAvis = 0;
$this->typeCompte = "Personnel";
$this->estSupprime = false;
$this->monPropreCodePromo = 'H'.random_int(100000, 999999);
}
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;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->username;
}
/**
* @see UserInterface
*/
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;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
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;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getSexe(): ?string
{
return $this->sexe;
}
public function setSexe(?string $sexe): self
{
$this->sexe = $sexe;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(?string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getNomComplet(): ?string
{
return $this->nomComplet;
}
public function setNomComplet(?string $nomComplet): self
{
$this->nomComplet = $nomComplet;
return $this;
}
/**
*
*/
public function getPlainPassword(): string
{
return $this->plainPassword;
}
public function setPlainPassword(string $plainPassword): self
{
$this->plainPassword = $plainPassword;
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getAvatar(): ?Photo
{
return $this->avatar;
}
public function setAvatar(?Photo $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getSlugUsername(): ?string
{
return $this->slugUsername;
}
public function setSlugUsername(string $slugUsername): self
{
$this->slugUsername = $slugUsername;
return $this;
}
/**
*@ORM\PreUpdate
*/
public function preUpdateClasse()
{
$this->formaterNom();
}
/**
* @ORM\PrePersist
*/
public function prePersistClasse()
{
$this->formaterNom();
}
public function formaterNom()
{
$this->nomComplet = $this->nom.' '.$this->prenom;
$this->username = $this->nom.$this->prenom.time();
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(?string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getTypeCompte(): ?string
{
return $this->typeCompte;
}
public function setTypeCompte(?string $typeCompte): self
{
$this->typeCompte = $typeCompte;
return $this;
}
/**
* @return mixed
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* @param mixed $enabled
* @return Users
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
return $this;
}
public function getMois(): ?string
{
return $this->mois;
}
public function setMois(?string $mois): self
{
$this->mois = $mois;
return $this;
}
public function getAnnee(): ?string
{
return $this->annee;
}
public function setAnnee(?string $annee): self
{
$this->annee = $annee;
return $this;
}
public function getNombreAvis(): ?int
{
return $this->nombreAvis;
}
public function setNombreAvis(?int $nombreAvis): self
{
$this->nombreAvis = $nombreAvis;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getQualification(): ?string
{
return $this->qualification;
}
public function setQualification(?string $qualification): self
{
$this->qualification = $qualification;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getDisponibilite(): ?string
{
return $this->disponibilite;
}
public function setDisponibilite(?string $disponibilite): self
{
$this->disponibilite = $disponibilite;
return $this;
}
public function getGammeDePrix(): ?string
{
return $this->gammeDePrix;
}
public function setGammeDePrix(?string $gammeDePrix): self
{
$this->gammeDePrix = $gammeDePrix;
return $this;
}
public function getMainDOeuvre(): ?string
{
return $this->mainDOeuvre;
}
public function setMainDOeuvre(?string $mainDOeuvre): self
{
$this->mainDOeuvre = $mainDOeuvre;
return $this;
}
public function getZoneDIntervention(): ?string
{
return $this->zoneDIntervention;
}
public function setZoneDIntervention(?string $zoneDIntervention): self
{
$this->zoneDIntervention = $zoneDIntervention;
return $this;
}
public function getDomaineDActivite(): ?string
{
return $this->domaineDActivite;
}
public function setDomaineDActivite(?string $domaineDActivite): self
{
$this->domaineDActivite = $domaineDActivite;
return $this;
}
public function isEstEmbassadeur(): ?bool
{
return $this->estEmbassadeur;
}
public function setEstEmbassadeur(?bool $estEmbassadeur): self
{
$this->estEmbassadeur = $estEmbassadeur;
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function getEmailToken(): ?string
{
return $this->emailToken;
}
public function setEmailToken(?string $emailToken): self
{
$this->emailToken = $emailToken;
return $this;
}
public function isEstSupprime(): ?bool
{
return $this->estSupprime;
}
public function setEstSupprime(?bool $estSupprime): self
{
$this->estSupprime = $estSupprime;
return $this;
}
public function getPieceDIdentiteRecto(): ?string
{
return $this->pieceDIdentiteRecto;
}
public function setPieceDIdentiteRecto(?string $pieceDIdentiteRecto): self
{
$this->pieceDIdentiteRecto = $pieceDIdentiteRecto;
return $this;
}
public function getPieceDIdentiteVerso(): ?string
{
return $this->pieceDIdentiteVerso;
}
public function setPieceDIdentiteVerso(?string $pieceDIdentiteVerso): self
{
$this->pieceDIdentiteVerso = $pieceDIdentiteVerso;
return $this;
}
public function getPushNotificationToken(): ?string
{
return $this->pushNotificationToken;
}
public function setPushNotificationToken(?string $pushNotificationToken): self
{
$this->pushNotificationToken = $pushNotificationToken;
return $this;
}
public function getMonPropreCodePromo(): ?string
{
return $this->monPropreCodePromo;
}
public function setMonPropreCodePromo(?string $monPropreCodePromo): self
{
$this->monPropreCodePromo = $monPropreCodePromo;
return $this;
}
public function getCodePromoUtilise(): ?string
{
return $this->codePromoUtilise;
}
public function setCodePromoUtilise(?string $codePromoUtilise): self
{
$this->codePromoUtilise = $codePromoUtilise;
return $this;
}
public function getTokenExpireAt(): ?float
{
return $this->tokenExpireAt;
}
public function setTokenExpireAt(?float $tokenExpireAt): self
{
$this->tokenExpireAt = $tokenExpireAt;
return $this;
}
public function getCasierJudiciaire(): ?string
{
return $this->casierJudiciaire;
}
public function setCasierJudiciaire(?string $casierJudiciaire): self
{
$this->casierJudiciaire = $casierJudiciaire;
return $this;
}
}