src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[ORM\Table(name'`users`')]
  12. #[UniqueEntity(fields: ['email'], message'Cet email existe déja')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column()]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $telephone null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $nom null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $prenoms null;
  32.     #[ORM\Column(length255nullablefalse)]
  33.     private ?string $email null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $boutique null;
  36.     #[ORM\Column(length100)]
  37.     private ?string $ville null;
  38.     #[ORM\Column(length20nullabletrue)]
  39.     private ?string $telwhatsapp null;
  40.     #[ORM\OneToMany(mappedBy'createdBy'targetEntityArticles::class)]
  41.     private Collection $articles;
  42.     #[ORM\Column]
  43.     private ?bool $isVerified null;
  44.     #[ORM\ManyToOne(inversedBy'users')]
  45.     private ?Boutiques $shop null;
  46.     #[ORM\OneToMany(mappedBy'vendeur'targetEntityImmeubles::class)]
  47.     private Collection $immeubles;
  48.     #[ORM\OneToMany(mappedBy'vendeur'targetEntityVehicules::class)]
  49.     private Collection $vehicules;
  50.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityFavoris::class)]
  51.     private Collection $favoris;
  52.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityUserCode::class)]
  53.     private Collection $userCodes;
  54.     public function __construct()
  55.     {
  56.         $this->articles = new ArrayCollection();
  57.         $this->immeubles = new ArrayCollection();
  58.         $this->vehicules = new ArrayCollection();
  59.         $this->favoris = new ArrayCollection();
  60.         $this->userCodes = new ArrayCollection();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getTelephone(): ?string
  67.     {
  68.         return $this->telephone;
  69.     }
  70.     public function setTelephone(string $telephone): self
  71.     {
  72.         $this->telephone $telephone;
  73.         return $this;
  74.     }
  75.     /**
  76.      * A visual identifier that represents this user.
  77.      *
  78.      * @see UserInterface
  79.      */
  80.     public function getUserIdentifier(): string
  81.     {
  82.         return (string) $this->telephone;
  83.     }
  84.     /**
  85.      * @see UserInterface
  86.      */
  87.     public function getRoles(): array
  88.     {
  89.         $roles $this->roles;
  90.         // guarantee every user at least has ROLE_USER
  91.         $roles[] = 'ROLE_USER';
  92.         return array_unique($roles);
  93.     }
  94.     public function setRoles(array $roles): self
  95.     {
  96.         $this->roles $roles;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @see PasswordAuthenticatedUserInterface
  101.      */
  102.     public function getPassword(): string
  103.     {
  104.         return $this->password;
  105.     }
  106.     public function setPassword(string $password): self
  107.     {
  108.         $this->password $password;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @see UserInterface
  113.      */
  114.     public function eraseCredentials()
  115.     {
  116.         // If you store any temporary, sensitive data on the user, clear it here
  117.         // $this->plainPassword = null;
  118.     }
  119.     public function getNom(): ?string
  120.     {
  121.         return $this->nom;
  122.     }
  123.     public function setNom(string $nom): self
  124.     {
  125.         $this->nom $nom;
  126.         return $this;
  127.     }
  128.     public function getPrenoms(): ?string
  129.     {
  130.         return $this->prenoms;
  131.     }
  132.     public function setPrenoms(string $prenoms): self
  133.     {
  134.         $this->prenoms $prenoms;
  135.         return $this;
  136.     }
  137.     public function getEmail(): ?string
  138.     {
  139.         return $this->email;
  140.     }
  141.     public function setEmail(?string $email): self
  142.     {
  143.         $this->email $email;
  144.         return $this;
  145.     }
  146.     public function getBoutique(): ?string
  147.     {
  148.         return $this->boutique;
  149.     }
  150.     public function setBoutique(?string $boutique): self
  151.     {
  152.         $this->boutique $boutique;
  153.         return $this;
  154.     }
  155.     public function getVille(): ?string
  156.     {
  157.         return $this->ville;
  158.     }
  159.     public function setVille(Villes $ville): self
  160.     {
  161.         $this->ville $ville->getNom();
  162.         return $this;
  163.     }
  164.     public function getTelwhatsapp(): ?string
  165.     {
  166.         return $this->telwhatsapp;
  167.     }
  168.     public function setTelwhatsapp(?string $telwhatsapp): self
  169.     {
  170.         $this->telwhatsapp $telwhatsapp;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return Collection<int, Articles>
  175.      */
  176.     public function getArticles(): Collection
  177.     {
  178.         return $this->articles;
  179.     }
  180.     public function addArticle(Articles $article): self
  181.     {
  182.         if (!$this->articles->contains($article)) {
  183.             $this->articles[] = $article;
  184.             $article->setCreatedBy($this);
  185.         }
  186.         return $this;
  187.     }
  188.     public function removeArticle(Articles $article): self
  189.     {
  190.         if ($this->articles->removeElement($article)) {
  191.             // set the owning side to null (unless already changed)
  192.             if ($article->getCreatedBy() === $this) {
  193.                 $article->setCreatedBy(null);
  194.             }
  195.         }
  196.         return $this;
  197.     }
  198.     public function isIsVerified(): ?bool
  199.     {
  200.         return $this->isVerified;
  201.     }
  202.     public function setIsVerified(bool $isVerified): self
  203.     {
  204.         $this->isVerified $isVerified;
  205.         return $this;
  206.     }
  207.     public function getShop(): ?Boutiques
  208.     {
  209.         return $this->shop;
  210.     }
  211.     public function setShop(?Boutiques $shop): self
  212.     {
  213.         $this->shop $shop;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, Immeubles>
  218.      */
  219.     public function getImmeubles(): Collection
  220.     {
  221.         return $this->immeubles;
  222.     }
  223.     public function addImmeuble(Immeubles $immeuble): self
  224.     {
  225.         if (!$this->immeubles->contains($immeuble)) {
  226.             $this->immeubles[] = $immeuble;
  227.             $immeuble->setVendeur($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeImmeuble(Immeubles $immeuble): self
  232.     {
  233.         if ($this->immeubles->removeElement($immeuble)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($immeuble->getVendeur() === $this) {
  236.                 $immeuble->setVendeur(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, Vehicules>
  243.      */
  244.     public function getVehicules(): Collection
  245.     {
  246.         return $this->vehicules;
  247.     }
  248.     public function addVehicule(Vehicules $vehicule): self
  249.     {
  250.         if (!$this->vehicules->contains($vehicule)) {
  251.             $this->vehicules[] = $vehicule;
  252.             $vehicule->setVendeur($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeVehicule(Vehicules $vehicule): self
  257.     {
  258.         if ($this->vehicules->removeElement($vehicule)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($vehicule->getVendeur() === $this) {
  261.                 $vehicule->setVendeur(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, Favoris>
  268.      */
  269.     public function getFavoris(): Collection
  270.     {
  271.         return $this->favoris;
  272.     }
  273.     public function addFavori(Favoris $favori): self
  274.     {
  275.         if (!$this->favoris->contains($favori)) {
  276.             $this->favoris->add($favori);
  277.             $favori->setUtilisateur($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeFavori(Favoris $favori): self
  282.     {
  283.         if ($this->favoris->removeElement($favori)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($favori->getUtilisateur() === $this) {
  286.                 $favori->setUtilisateur(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, UserCode>
  293.      */
  294.     public function getUserCodes(): Collection
  295.     {
  296.         return $this->userCodes;
  297.     }
  298.     public function addUserCode(UserCode $userCode): static
  299.     {
  300.         if (!$this->userCodes->contains($userCode)) {
  301.             $this->userCodes->add($userCode);
  302.             $userCode->setUtilisateur($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeUserCode(UserCode $userCode): static
  307.     {
  308.         if ($this->userCodes->removeElement($userCode)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($userCode->getUtilisateur() === $this) {
  311.                 $userCode->setUtilisateur(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316. }