<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Users
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
* @ORM\Table(name="app_user")
*/
class AppUser implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @Gedmo\Slug(fields={"username"})
* @ORM\Column(length=128, unique=true)
*/
private $slugUsername;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $username;
/**
* @var string
*/
private $plainPassword;
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @ORM\ManyToOne(targetEntity="\App\Entity\Boutique")
*/
private $boutique;
const ROLES = [
'ROLE_SUPER_ADMIN' => 'Super Administrateur',
'ROLE_ENTREPRISE' => 'Entreprise',
'ROLE_PARTICULIER' => 'Particulier',
];
/**
* @ORM\OneToOne(targetEntity="\App\Entity\Photo", cascade={"persist", "remove"})
*/
private $avatar;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/*
* @var string
*
* @ORM\Column(name="nomprenoms", type="string", length=255, nullable=true)
*/
private $nomprenoms;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $emailToken;
/**
* @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="nom_complet", type="string", length=255, nullable=true)
*/
private $nomComplet;
/**
* @var string
*
* @ORM\Column(name="dateNaissance", type="date", nullable=true)
*/
private $dateNaissance;
/**
* @var string
*
* @ORM\Column(name="contacts", type="string", length=255, nullable=true)
*/
private $contacts;
/**
* @var string|null
*
* @ORM\Column(name="adresse", type="string", length=255, nullable=true)
*/
private $adresse;
/**
* @var string|null
*
* @ORM\Column(name="matricule", type="string", length=255, nullable=true)
*/
private $matricule;
/**
* @var string|null
*
* @ORM\Column(name="salaire", type="float", nullable=true)
*/
private $salaire;
/**
* @var string|null
*
* @ORM\Column(name="numero_cnps", type="string", length=255, nullable=true)
*/
private $numeroCNPS;
/**
* @var string|null
*
* @ORM\Column(name="vacataire", type="boolean", nullable=true)
*/
private $vacataire;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
/**
* @var \DateTime|null
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
//Sync from main base piliersoft
public function __construct()
{
$this->roles = ['ROLE_USER'];
$this->createdAt = new \DateTime('now');
$p = new Photo;
$fullUrl = '';
$domaine = $_SERVER['HTTP_HOST'];
$protocol = '';
if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'){
$protocol = 'https://';
} else{
$protocol = 'http://';
}
$fullUrl = $protocol.$domaine.'/image/male-user.png';
$p->setFullUrl($fullUrl);
$p->setUrl('image/male-user.png');
$p->setAlt('Photo de profile');
$this->avatar = $p;
}
public function getId(): ?int
{
return $this->id;
}
public function getNomprenoms(): ?string
{
return $this->nomprenoms;
}
public function setNomprenoms(string $nomprenoms): self
{
$this->nomprenoms = $nomprenoms;
return $this;
}
public function getContacts(): ?string
{
return $this->contacts;
}
public function setContacts(string $contacts): self
{
$this->contacts = $contacts;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(?string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getRolesUsers(): string {
return self::ROLES[$this->role];
}
/**
* @return mixed
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* @param mixed $enabled
* @return Users
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
return $this;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(?string $filename): self
{
$this->filename = $filename;
return $this;
}
public function getBoutique(): ?Boutique
{
return $this->boutique;
}
public function setBoutique(?Boutique $boutique): self
{
$this->boutique = $boutique;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getNomComplet(): ?string
{
return $this->nomComplet;
}
public function setNomComplet(?string $nomComplet): self
{
$this->nomComplet = $nomComplet;
return $this;
}
public function getDateNaissance(): ?\DateTimeInterface
{
return $this->dateNaissance;
}
public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
{
$this->dateNaissance = $dateNaissance;
return $this;
}
public function getSalaire(): ?float
{
return $this->salaire;
}
public function setSalaire(?float $salaire): self
{
$this->salaire = $salaire;
return $this;
}
public function getVacataire(): ?bool
{
return $this->vacataire;
}
public function setVacataire(?bool $vacataire): self
{
$this->vacataire = $vacataire;
return $this;
}
public function getMatricule(): ?string
{
return $this->matricule;
}
public function setMatricule(?string $matricule): self
{
$this->matricule = $matricule;
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 getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function isVacataire(): ?bool
{
return $this->vacataire;
}
public function getSlugUsername(): ?string
{
return $this->slugUsername;
}
public function setSlugUsername(string $slugUsername): self
{
$this->slugUsername = $slugUsername;
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
*
*/
public function getPlainPassword(): string
{
return $this->plainPassword;
}
public function setPlainPassword(string $plainPassword): self
{
$this->plainPassword = $plainPassword;
return $this;
}
public function getAvatar(): ?Photo
{
return $this->avatar;
}
public function setAvatar(?Photo $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getNumeroCNPS(): ?string
{
return $this->numeroCNPS;
}
public function setNumeroCNPS(?string $numeroCNPS): self
{
$this->numeroCNPS = $numeroCNPS;
return $this;
}
/**
*@ORM\PreUpdate
*/
public function persistEntity()
{
$this->nomComplet = $this->getNom().' '.$this->getPrenom();
}
/**
*@ORM\PrePersist
*/
public function updateEntity()
{
$this->nomComplet = $this->getNom().' '.$this->getPrenom();
}
public function getEmailToken(): ?string
{
return $this->emailToken;
}
public function setEmailToken(?string $emailToken): self
{
$this->emailToken = $emailToken;
return $this;
}
}