src/Entity/User.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\EntityListener\UserListener;
  4. use Doctrine\DBAL\Types\Types;
  5. use App\Traits\TimstampleTrait;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Repository\UserRepository;
  8. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Security\Core\User\UserInterface;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Doctrine\Common\Collections\Collection;
  15. #[ORM\Entity(repositoryClassUserRepository::class)]
  16. #[ORM\EntityListeners([UserListener::class])]
  17. #[ORM\Table(name'`user`')]
  18. #[HasLifecycleCallbacks]
  19. class User implements UserInterfacePasswordAuthenticatedUserInterface
  20. {
  21.     use TimstampleTrait;
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     #[Groups(["show_event""show_commande""list_achatVente""show_achatVente"
  26.      "list_animaux""show_animal""list_appelOffre""show_appelOffre"
  27.      "list_bateaux""show_bateau""list_communiques""show_communique""list_emplois"
  28.      "show_emploi""list_formations""show_formation""list_mariages""show_mariage"
  29.      "list_modes""show_mode""list_motos""show_moto""list_naissances""show_naissance""list_objets"
  30.      "show_objet""list_proprietes""show_propriete""all_alaune_abj","app_group""immo_ci",
  31.      "list_personnels""show_personnel""list_rencontres""show_rencontre""list_vehicules""show_vehicule""list_users""show_user""list_admins""show_admin"])]
  32.     private ?int $id null;
  33.     #[ORM\Column(length100uniquetrue)]
  34.     #[Assert\NotBlank(message'veuillez entrer votre adresse email')]
  35.     #[Assert\Email(message'veuillez entrer une adresse email valide')]
  36.     #[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"])]
  37.     private ?string $email null;
  38.     #[ORM\Column]
  39.     #[Assert\NotNull()]
  40.     private array $roles = [];
  41.     #[ORM\Column(length180)]
  42.     #[Groups(["show_achatVente""list_animaux""show_animal""list_appelOffre""show_appelOffre"
  43.     "list_bateaux""list_users""show_bateau""list_communiques""show_communique""list_emplois"
  44.     "show_emploi""list_formations""show_formation""list_mariages""show_mariage""list_modes"
  45.     "show_mode""list_motos""show_moto""list_naissances""show_naissance"
  46.     "list_objets""show_objet""show_propriete""list_personnels""show_personnel","list_admins""show_admin""list_rencontres""show_rencontre""list_vehicules""show_vehicule""show_user"])]
  47.     private ?string $username null;
  48.     #[ORM\Column(length255nullabletrue)]
  49.     #[Groups(["show_user"])]
  50.     private ?string $adresse null;
  51.     #[ORM\Column(length255)]
  52.     #[Assert\NotBlank(message'veuillez entrer votre mot de passe')]
  53.     #[Assert\Length(min:6)]
  54.     private ?string $password 'password';
  55.     #[ORM\Column(length255nullabletrue)]
  56.     #[Groups(["show_event""list_users""show_commande""show_achatVente""show_animal""show_appelOffre"
  57.     "show_bateau""show_communique""show_emploi""show_formation""show_mariage"
  58.     "show_mode""show_moto""show_naissance""show_objet""show_propriete""show_personnel""show_rencontre""show_vehicule""show_user"])]
  59.     private ?string $ville=null;
  60.     #[ORM\Column(length255nullabletrue)]
  61.     #[Groups(["show_event""list_users""show_commande""show_achatVente""show_animal""show_appelOffre"
  62.     "show_bateau""show_communique""show_emploi""show_formation""show_mariage"
  63.     "show_mode""show_moto""show_naissance""show_objet""show_propriete""show_personnel""show_rencontre""show_vehicule""show_user"])]
  64.     private ?string $pays=null;
  65.     #[ORM\Column(length255nullabletrue)]
  66.     #[Groups(["show_event""show_achatVente""show_animal""show_bateau""show_communique"
  67.     "show_emploi""show_formation""show_mariage""show_mode""show_moto""show_naissance""show_objet""show_user""show_propriete""show_personnel""show_rencontre""show_vehicule"])]
  68.     private ?string $lienFacebook;
  69.     #[ORM\Column(length25nullabletrue)]
  70.     private $dialCode;
  71.     #[ORM\Column(length255nullabletrue)]
  72.     #[Groups(["show_event""show_achatVente""show_animal""show_bateau""show_communique"
  73.     "show_emploi""show_formation""show_mariage""show_mode""show_moto""show_naissance""show_objet""show_user""show_propriete""show_personnel""show_rencontre""show_vehicule"])]
  74.     private ?string $lienSiteWeb;
  75.     #[ORM\Column()]
  76.     #[Groups(["show_event""list_users""show_achatVente""show_animal""show_appelOffre""show_bateau"
  77.     "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"])]
  78.     private ?bool $actif =false;
  79.     #[ORM\Column(length255)]
  80.     #[Assert\NotBlank(message'veuillez entrer votre nom')]
  81.     #[Assert\Length(min:2max:50)]
  82.     #[Groups(["show_event""show_commande""list_achatVente""show_achatVente"
  83.     "list_animaux""show_animal""list_appelOffre""show_appelOffre""list_bateaux""show_bateau"
  84.     "list_communiques""show_communique""list_emplois""show_emploi""list_formations""list_commande_ticket",
  85.     "show_formation""list_mariages""show_mariage""list_modes""show_mode""list_motos""show_moto""list_users",
  86.     "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"])]
  87.     private ?string $nom;
  88.     #[ORM\Column(length255)]
  89.     #[Assert\NotBlank(message'veuillez entrer votre prénom')]
  90.     #[Assert\Length(min:2max:50)]
  91.     #[Groups(["show_event""show_commande""list_achatVente""show_achatVente""list_users",
  92.     "list_animaux""show_animal""list_appelOffre""show_appelOffre""list_bateaux""show_bateau"
  93.     "list_communiques""show_communique""list_emplois""show_emploi""list_formations""list_commande_ticket",
  94.     "show_formation""list_mariages""show_mariage""list_modes""show_mode""list_motos"
  95.     "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"])]
  96.     private ?string $prenoms;
  97.     #[ORM\Column(length255)]
  98.     #[Groups(["list_users""show_user""list_admins""show_admin""all_alaune_abj""app_group""all_waiting""immo_ci"])]
  99.     private ?string $nomComplet;
  100.      #[ORM\Column()]
  101.     #[Groups(["list_users"])]
  102.     private ?bool $isAdmin =null;
  103.      #[ORM\Column(length255nullabletrue)]
  104.     #[Groups(["list_users""show_user"])]
  105.     private ?string $typeCompte =null;
  106.     #[ORM\Column(length255)]
  107.     #[Assert\NotBlank(message'veuillez entrer votre numéro de téléphone')]
  108.     #[Groups(["show_achatVente","list_users""show_user","show_animal""show_appelOffre""show_bateau""show_communique""show_emploi"
  109.     "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"])]
  110.     private ?string $numero;
  111.     #[ORM\Column(length255nullabletrue)]
  112.     #[Groups(["list_users""show_user""list_admins""show_admin""all_alaune_abj""immo_ci"])]
  113.     private $photo;
  114.     #[ORM\OneToMany(targetEntityUserSessions::class, mappedBy'user'orphanRemovaltrue)]
  115.     private $userSessions;
  116.     #[ORM\Column(length255nullabletrue)]
  117.     private ?string $source;//abj,annonce,ticket,news,business...
  118.     #[ORM\Column(typeTypes::DATETIME_MUTABLE,nullabletrue)]
  119.     private ?\DateTimeInterface $passwordRequestedAt null;
  120.     #[ORM\Column()]
  121.     private ?bool $emailVerified =false;
  122.     #[ORM\Column(length255nullabletrue)]
  123.     private ?string $token;
  124.     private $plainPassword;
  125.     private $newPassword;
  126.       public function __construct()
  127.     {
  128.         $this->userSessions = new ArrayCollection();
  129.         $this->emailVerified false;
  130.     }
  131.     public function getId(): ?int
  132.     {
  133.         return $this->id;
  134.     }
  135.     public function getEmail(): ?string
  136.     {
  137.         return $this->email;
  138.     }
  139.     public function setEmail(string $email): static
  140.     {
  141.         $this->email $email;
  142.         return $this;
  143.     }
  144.     public function getUsername(): ?string
  145.     {
  146.         return $this->username;
  147.     }
  148.     public function setUsername(string $username): static
  149.     {
  150.         $this->username $username;
  151.         return $this;
  152.     }
  153.     public function getAdresse(): ?string
  154.     {
  155.         return $this->adresse;
  156.     }
  157.     public function setAdresse(?string $adresse): static
  158.     {
  159.         $this->adresse $adresse;
  160.         return $this;
  161.     }
  162.      public function getRoles(): array
  163.     {
  164.         $roles $this->roles;
  165.         // guarantee every user at least has ROLE_USER
  166.         $roles[] = 'ROLE_USER';
  167.         return array_unique($roles);
  168.     }
  169.     public function setRoles(array $roles): self
  170.     {
  171.         $this->roles $roles;
  172.         return $this;
  173.     }
  174.     public function getPassword(): ?string
  175.     {
  176.         return $this->password;
  177.     }
  178.     public function setPassword(string $password): self
  179.     {
  180.         $this->password $password;
  181.         return $this;
  182.     }
  183.     public function getVille(): ?string
  184.     {
  185.         return $this->ville;
  186.     }
  187.     public function setVille(?string $ville): self
  188.     {
  189.         $this->ville $ville;
  190.         return $this;
  191.     }
  192.     public function getPays(): ?string
  193.     {
  194.         return $this->pays;
  195.     }
  196.     public function setPays(?string $pays): self
  197.     {
  198.         $this->pays $pays;
  199.         return $this;
  200.     }
  201.     public function getLienFacebook(): ?string
  202.     {
  203.         return $this->lienFacebook;
  204.     }
  205.     public function setLienFacebook(?string $lienFacebook): self
  206.     {
  207.         $this->lienFacebook $lienFacebook;
  208.         return $this;
  209.     }
  210.     public function getDialCode(): ?string
  211.     {
  212.         return $this->dialCode;
  213.     }
  214.     public function setDialCode(?string $dialCode): self
  215.     {
  216.         $this->dialCode $dialCode;
  217.         return $this;
  218.     }
  219.     public function getLienSiteWeb(): ?string
  220.     {
  221.         return $this->lienSiteWeb;
  222.     }
  223.     public function setLienSiteWeb(?string $lienSiteWeb): self
  224.     {
  225.         $this->lienSiteWeb $lienSiteWeb;
  226.         return $this;
  227.     }
  228.     public function isActif(): ?bool
  229.     {
  230.         return $this->actif;
  231.     }
  232.     public function setActif(bool $actif): self
  233.     {
  234.         $this->actif $actif;
  235.         return $this;
  236.     }
  237.     public function getNom(): ?string
  238.     {
  239.         return $this->nom;
  240.     }
  241.     public function setNom(string $nom): self
  242.     {
  243.         $this->nom $nom;
  244.         return $this;
  245.     }
  246.     public function getPrenoms(): ?string
  247.     {
  248.         return $this->prenoms;
  249.     }
  250.     public function setPrenoms(string $prenoms): self
  251.     {
  252.         $this->prenoms $prenoms;
  253.         return $this;
  254.     }
  255.     public function getNomComplet(): ?string
  256.     {
  257.         return $this->nomComplet;
  258.     }
  259.     public function setNomComplet(string $nomComplet): self
  260.     {
  261.         $this->nomComplet $nomComplet;
  262.         return $this;
  263.     }
  264.     public function getIsAdmin(): ?bool
  265.     {
  266.         return $this->isAdmin;
  267.     }
  268.     public function setIsAdmin(bool $isAdmin): self
  269.     {
  270.         $this->isAdmin $isAdmin;
  271.         return $this;
  272.     }
  273.     public function getTypeCompte(): ?string
  274.     {
  275.         return $this->typeCompte;
  276.     }
  277.     public function setTypeCompte(?string $typeCompte): self
  278.     {
  279.         $this->typeCompte $typeCompte;
  280.         return $this;
  281.     }
  282.     public function getNumero(): ?string
  283.     {
  284.         return $this->numero;
  285.     }
  286.     public function setNumero(string $numero): self
  287.     {
  288.         $this->numero $numero;
  289.         return $this;
  290.     }
  291.     public function getPhoto(): ?string
  292.     {
  293.         return $this->photo;
  294.     }
  295.     public function setPhoto(?string $photo): self
  296.     {
  297.         $this->photo $photo;
  298.         return $this;
  299.     }
  300.     public function getPasswordRequestedAt(): ?\DateTimeInterface
  301.     {
  302.         return $this->passwordRequestedAt;
  303.     }
  304.     public function setPasswordRequestedAt(?\DateTimeInterface $passwordRequestedAt): self
  305.     {
  306.         $this->passwordRequestedAt $passwordRequestedAt;
  307.         return $this;
  308.     }
  309.     public function getEmailVerified(): ?bool
  310.     {
  311.         return $this->emailVerified;
  312.     }
  313.     public function setEmailVerified(bool $emailVerified): self
  314.     {
  315.         $this->emailVerified $emailVerified;
  316.         return $this;
  317.     }
  318.     public function getToken(): ?string
  319.     {
  320.         return $this->token;
  321.     }
  322.     public function setToken(?string $token): self
  323.     {
  324.         $this->token $token;
  325.         return $this;
  326.     }
  327.     public function getPlainPassword(): ?string
  328.     {
  329.         return $this->plainPassword;
  330.     }
  331.     public function setPlainPassword(?string $plainPassword): self
  332.     {
  333.         $this->plainPassword $plainPassword;
  334.         return $this;
  335.     }
  336.      public function __toString()
  337.     {
  338.         return $this->nom;
  339.     }
  340.     public function getNewPassword(): ?string
  341.     {
  342.         return $this->newPassword;
  343.     }
  344.     public function setNewPassword(?string $newPassword): self
  345.     {
  346.         $this->newPassword $newPassword;
  347.         return $this;
  348.     }
  349.     
  350.     /**
  351.      * Returning a salt is only needed, if you are not using a modern
  352.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  353.      *
  354.      * @see UserInterface
  355.      */
  356.     public function getSalt(): ?string
  357.     {
  358.         return null;
  359.     }
  360.     public function getUserIdentifier(): string
  361.     {
  362.         return (string) $this->email;
  363.     }
  364.     public function eraseCredentials(): void
  365.     {
  366.         // If you store any temporary, sensitive data on the user, clear it here
  367.         // $this->plainPassword = null;
  368.     }
  369.     /**
  370.      * Get the value of source
  371.      */ 
  372.     public function getSource()
  373.     {
  374.         return $this->source;
  375.     }
  376.     /**
  377.      * Set the value of from
  378.      *
  379.      * @return  self
  380.      */ 
  381.     public function setSource($source)
  382.     {
  383.         $this->source $source;
  384.         return $this;
  385.     }
  386.         /**
  387.      * @return Collection<int, UserSessions>
  388.      */
  389.     public function getUserSessions(): Collection
  390.     {
  391.         return $this->userSessions;
  392.     }
  393.     public function addUserSession(UserSessions $userSession): self
  394.     {
  395.         if (!$this->userSessions->contains($userSession)) {
  396.             $this->userSessions[] = $userSession;
  397.             $userSession->setUser($this);
  398.         }
  399.         return $this;
  400.     }
  401.     public function removeUserSession(UserSessions $userSession): self
  402.     {
  403.         if ($this->userSessions->removeElement($userSession)) {
  404.             // set the owning side to null (unless already changed)
  405.             if ($userSession->getUser() === $this) {
  406.                 $userSession->setUser(null);
  407.             }
  408.         }
  409.         return $this;
  410.     }
  411. }