src/Entity/ClientUser.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Traits\Ficherdate;
  7. use App\Repository\ClientUserRepository;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ClientUserRepository::class)
  13.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  14.  * @ORM\HasLifecycleCallbacks
  15.  */
  16. class ClientUser implements UserInterfacePasswordAuthenticatedUserInterface
  17. {
  18.     use Ficherdate;
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=180, unique=true)
  27.      */
  28.     private $email;
  29.     /**
  30.      * @ORM\Column(type="json")
  31.      */
  32.     private $roles = [];
  33.     /**
  34.      * @var string The hashed password
  35.      * @ORM\Column(type="string")
  36.      */
  37.     private $password;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      */
  41.     private $nom;
  42.     /**
  43.      * @ORM\Column(type="string", length=255)
  44.      */
  45.     private $prenom;
  46.     /**
  47.      * @ORM\Column(type="string", length=255)
  48.      */
  49.     private $numero;
  50.     /**
  51.      * @ORM\Column(type="boolean")
  52.      */
  53.     private $isVerified false;
  54.     /**
  55.      * @ORM\Column(type="string", length=255)
  56.      */
  57.     private $compte;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=Livraison::class, mappedBy="userClient", orphanRemoval=true)
  60.      */
  61.     private $livraisons;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity=Suivre::class, mappedBy="userClient", orphanRemoval=true)
  64.      */
  65.     private $suivres;
  66.     public function __construct()
  67.     {
  68.         $this->livraisons = new ArrayCollection();
  69.         $this->suivres = new ArrayCollection();
  70.         $this->couvertureProfils = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getEmail(): ?string
  77.     {
  78.         return $this->email;
  79.     }
  80.     public function setEmail(string $email): self
  81.     {
  82.         $this->email $email;
  83.         return $this;
  84.     }
  85.     /**
  86.      * A visual identifier that represents this user.
  87.      *
  88.      * @see UserInterface
  89.      */
  90.     public function getUserIdentifier(): string
  91.     {
  92.         return (string) $this->email;
  93.     }
  94.     /**
  95.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  96.      */
  97.     public function getUsername(): string
  98.     {
  99.         return (string) $this->email;
  100.     }
  101.     /**
  102.      * @see UserInterface
  103.      */
  104.     public function getRoles(): array
  105.     {
  106.         $roles $this->roles;
  107.         // guarantee every user at least has ROLE_USER
  108.         $roles[] = 'ROLE_USER';
  109.         return array_unique($roles);
  110.     }
  111.     public function setRoles(array $roles): self
  112.     {
  113.         $this->roles $roles;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @see PasswordAuthenticatedUserInterface
  118.      */
  119.     public function getPassword(): string
  120.     {
  121.         return $this->password;
  122.     }
  123.     public function setPassword(string $password): self
  124.     {
  125.         $this->password $password;
  126.         return $this;
  127.     }
  128.     /**
  129.      * Returning a salt is only needed, if you are not using a modern
  130.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  131.      *
  132.      * @see UserInterface
  133.      */
  134.     public function getSalt(): ?string
  135.     {
  136.         return null;
  137.     }
  138.     /**
  139.      * @see UserInterface
  140.      */
  141.     public function eraseCredentials()
  142.     {
  143.         // If you store any temporary, sensitive data on the user, clear it here
  144.         // $this->plainPassword = null;
  145.     }
  146.     public function getNom(): ?string
  147.     {
  148.         return $this->nom;
  149.     }
  150.     public function setNom(string $nom): self
  151.     {
  152.         $this->nom $nom;
  153.         return $this;
  154.     }
  155.     public function getPrenom(): ?string
  156.     {
  157.         return $this->prenom;
  158.     }
  159.     public function setPrenom(string $prenom): self
  160.     {
  161.         $this->prenom $prenom;
  162.         return $this;
  163.     }
  164.     public function getNumero(): ?string
  165.     {
  166.         return $this->numero;
  167.     }
  168.     public function setNumero(string $numero): self
  169.     {
  170.         $this->numero $numero;
  171.         return $this;
  172.     }
  173.     public function getToutleNom(): string
  174.     {
  175.         return $this->getNom() . ' ' $this->getPrenom();
  176.     }
  177.     public function isVerified(): bool
  178.     {
  179.         return $this->isVerified;
  180.     }
  181.     public function setIsVerified(bool $isVerified): self
  182.     {
  183.         $this->isVerified $isVerified;
  184.         return $this;
  185.     }
  186.     public function getCompte(): ?string
  187.     {
  188.         return $this->compte;
  189.     }
  190.     public function setCompte(string $compte): self
  191.     {
  192.         $this->compte $compte;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Livraison>
  197.      */
  198.     public function getLivraisons(): Collection
  199.     {
  200.         return $this->livraisons;
  201.     }
  202.     public function addLivraison(Livraison $livraison): self
  203.     {
  204.         if (!$this->livraisons->contains($livraison)) {
  205.             $this->livraisons[] = $livraison;
  206.             $livraison->setUserClient($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeLivraison(Livraison $livraison): self
  211.     {
  212.         if ($this->livraisons->removeElement($livraison)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($livraison->getUserClient() === $this) {
  215.                 $livraison->setUserClient(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Suivre>
  222.      */
  223.     public function getSuivres(): Collection
  224.     {
  225.         return $this->suivres;
  226.     }
  227.     public function addSuivre(Suivre $suivre): self
  228.     {
  229.         if (!$this->suivres->contains($suivre)) {
  230.             $this->suivres[] = $suivre;
  231.             $suivre->setUserClient($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeSuivre(Suivre $suivre): self
  236.     {
  237.         if ($this->suivres->removeElement($suivre)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($suivre->getUserClient() === $this) {
  240.                 $suivre->setUserClient(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245. }