<?php
namespace App\Entity;
use App\Enum\Ville;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity("email" , message="Cette adresse est déja utiliseé")
* @Vich\Uploadable
*/
class User implements UserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email."
* )
* @Assert\NotBlank(
* message= "champs email est obligatiore."
* )
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string",nullable=true)
* @Assert\NotBlank(
* message= "champs password est obligatiore."
* )
* @Assert\Length(min="8", minMessage="Votre mot de passe doit faire minimum 8 caractéres")
* @Assert\EqualTo(propertyPath="confirm_password", message="Le mot de passe et sa confirmation ne coïncident pas. ")
*/
private $password;
/**
* @Assert\NotBlank(
* message= "champs confirm password est obligatiore."
* )
* @Assert\EqualTo(propertyPath="password")
*/
public $confirm_password;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(
* message= "champs username est obligatiore."
* )
*/
private $username;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(
* message= "champs lastname est obligatiore."
* )
*/
private $lastname;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(
* message= "champs phone est obligatiore."
* )
* @Assert\Length(min="8", minMessage="Votre numreo de Télèphone doit contenir 8 chiffres")
*/
private $phone;
/**
* @ORM\Column(type="string", length=255,nullable=true)
* @Assert\NotBlank(
* message= "champs address est obligatiore."
* )
*/
private $address;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(
* message= "champs ville est obligatiore."
* )
*/
private $ville;
/**
* @ORM\OneToMany(targetEntity=Demande::class, mappedBy="user")
*/
private $demandes;
/**
* @ORM\OneToMany(targetEntity=Comments::class, mappedBy="user")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity=Offre::class, mappedBy="user")
*/
private $offres;
/**
* @ORM\OneToMany(targetEntity=CommentOffre::class, mappedBy="user")
*/
private $commentOffres;
/**
* @ORM\OneToOne(targetEntity=UserImage::class, mappedBy="userImages", cascade={"persist", "remove"})
*/
private $userImage;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $reset_token;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Assert\NotBlank(
* message= "champs date naissance est obligatiore."
* )
*/
private $naissance;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $experience;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\Length(
* min = 10,
* max = 12,
* minMessage = "numéro social doit avoir {{ limit }} chiffres minimum",
* maxMessage = "Numéro social doit avoir {{ limit }} chiffres maximum"
* )
*/
private $sociale;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\Length(
* min = 20,
* max = 20,
* minMessage = "numéro bancaire doit avoir {{ limit }} chiffres minimum",
* maxMessage = "Numéro bancaire doit avoir {{ limit }} chiffres maximum"
* )
*/
private $bancaire;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $cv;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $identite;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $logo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $etablissement;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $a_propos;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Length(
* min = 8,
* max = 12,
* minMessage = "numéro matricule doit avoir {{ limit }} chiffres minimum",
* maxMessage = "Numéro matricule doit avoir {{ limit }} chiffres maximum"
* )
*/
private $matricule;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isBlocked;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $enabled;
/**
* @ORM\OneToMany(targetEntity=Candidature::class, mappedBy="user")
*/
private $candidatures;
public function __construct()
{
$this->roles = ['ROLE_USER'];
$this->createdAt = new \DateTime();
$this->enabled = false;
$this->isBlocked = false;
$this->demandes = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->offres = new ArrayCollection();
$this->commentOffres = new ArrayCollection();
$this->candidatures = new ArrayCollection();
}
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 getUsername(): string
{
//return (string) $this->email;
return $this->username;
}
public function getEtablissement(): ?string
{
return $this->etablissement;
}
public function setEtablissement(?string $etablissement): self
{
$this->etablissement = $etablissement;
return $this;
}
public function getAPropos(): ?string
{
return $this->a_propos;
}
public function setAPropos(?string $a_propos): self
{
$this->a_propos = $a_propos;
return $this;
}
public function getMatricule(): ?string
{
return $this->matricule;
}
public function setMatricule(?string $matricule): self
{
$this->matricule = $matricule;
return $this;
}
/**
* @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 UserInterface
*/
public function getPassword(): string
{
return (string) $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 getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
/**
* @return Collection|Demande[]
*/
public function getDemandes(): Collection
{
return $this->demandes;
}
public function addDemande(Demande $demande): self
{
if (!$this->demandes->contains($demande)) {
$this->demandes[] = $demande;
$demande->setUser($this);
}
return $this;
}
public function removeDemande(Demande $demande): self
{
if ($this->demandes->removeElement($demande)) {
// set the owning side to null (unless already changed)
if ($demande->getUser() === $this) {
$demande->setUser(null);
}
}
return $this;
}
public function __toString()
{
return $this->username;
}
/**
* @return Collection|Comments[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comments $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setUser($this);
}
return $this;
}
public function removeComment(Comments $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getUser() === $this) {
$comment->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Offre[]
*/
public function getOffres(): Collection
{
return $this->offres;
}
public function addOffre(Offre $offre): self
{
if (!$this->offres->contains($offre)) {
$this->offres[] = $offre;
$offre->setUser($this);
}
return $this;
}
public function removeOffre(Offre $offre): self
{
if ($this->offres->removeElement($offre)) {
// set the owning side to null (unless already changed)
if ($offre->getUser() === $this) {
$offre->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CommentOffre[]
*/
public function getCommentOffres(): Collection
{
return $this->commentOffres;
}
public function addCommentOffre(CommentOffre $commentOffre): self
{
if (!$this->commentOffres->contains($commentOffre)) {
$this->commentOffres[] = $commentOffre;
$commentOffre->setUser($this);
}
return $this;
}
public function removeCommentOffre(CommentOffre $commentOffre): self
{
if ($this->commentOffres->removeElement($commentOffre)) {
// set the owning side to null (unless already changed)
if ($commentOffre->getUser() === $this) {
$commentOffre->setUser(null);
}
}
return $this;
}
public function getUserImage(): ?UserImage
{
return $this->userImage;
}
public function setUserImage(?UserImage $userImage): self
{
// unset the owning side of the relation if necessary
if ($userImage === null && $this->userImage !== null) {
$this->userImage->setUserImages(null);
}
// set the owning side of the relation if necessary
if ($userImage !== null && $userImage->getUserImages() !== $this) {
$userImage->setUserImages($this);
}
$this->userImage = $userImage;
return $this;
}
public function getResetToken(): ?string
{
return $this->reset_token;
}
public function setResetToken(?string $reset_token): self
{
$this->reset_token = $reset_token;
return $this;
}
public function getNaissance(): ?Datetime
{
return $this->naissance;
}
public function setNaissance(DateTime $naissance): self
{
$this->naissance = $naissance;
return $this;
}
public function getExperience(): ?string
{
return $this->experience;
}
public function setExperience(string $experience): self
{
$this->experience = $experience;
return $this;
}
public function getSociale(): ?string
{
return $this->sociale;
}
public function setSociale(string $sociale): self
{
$this->sociale = $sociale;
return $this;
}
public function getBancaire(): ?string
{
return $this->bancaire;
}
public function setBancaire(string $bancaire): self
{
$this->bancaire = $bancaire;
return $this;
}
public function getCv(): ?string
{
return $this->cv;
}
public function setLogo(string $logo): self
{
$this->logo = $logo;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setCv(string $cv): self
{
$this->cv = $cv;
return $this;
}
public function getIdentite(): ?string
{
return $this->identite;
}
public function setIdentite(string $identite): self
{
$this->identite = $identite;
return $this;
}
public function getIsBlocked(): ?bool
{
return $this->isBlocked;
}
public function setIsBlocked(bool $isBlocked): self
{
$this->isBlocked = $isBlocked;
return $this;
}
/**
* @return Collection|Candidature[]
*/
public function getCandidatures(): Collection
{
return $this->candidatures;
}
public function addCandidature(Candidature $candidature): self
{
if (!$this->candidatures->contains($candidature)) {
$this->candidatures[] = $candidature;
$candidature->setUser($this);
}
return $this;
}
public function removeCandidature(Candidature $candidature): self
{
if ($this->candidatures->removeElement($candidature)) {
// set the owning side to null (unless already changed)
if ($candidature->getUser() === $this) {
$candidature->setUser(null);
}
}
return $this;
}
}