src/Entity/User.php line 16

  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.     #[ORM\OneToMany(mappedBy'created_by'targetEntityServices::class)]
  55.     private Collection $services;
  56.     public function __construct()
  57.     {
  58.         $this->articles = new ArrayCollection();
  59.         $this->immeubles = new ArrayCollection();
  60.         $this->vehicules = new ArrayCollection();
  61.         $this->favoris = new ArrayCollection();
  62.         $this->userCodes = new ArrayCollection();
  63.         $this->services = new ArrayCollection();
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getTelephone(): ?string
  70.     {
  71.         return $this->telephone;
  72.     }
  73.     public function setTelephone(string $telephone): self
  74.     {
  75.         $this->telephone $telephone;
  76.         return $this;
  77.     }
  78.     /**
  79.      * A visual identifier that represents this user.
  80.      *
  81.      * @see UserInterface
  82.      */
  83.     public function getUserIdentifier(): string
  84.     {
  85.         return (string) $this->telephone;
  86.     }
  87.     /**
  88.      * @see UserInterface
  89.      */
  90.     public function getRoles(): array
  91.     {
  92.         $roles $this->roles;
  93.         // guarantee every user at least has ROLE_USER
  94.         $roles[] = 'ROLE_USER';
  95.         return array_unique($roles);
  96.     }
  97.     public function setRoles(array $roles): self
  98.     {
  99.         $this->roles $roles;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @see PasswordAuthenticatedUserInterface
  104.      */
  105.     public function getPassword(): string
  106.     {
  107.         return $this->password;
  108.     }
  109.     public function setPassword(string $password): self
  110.     {
  111.         $this->password $password;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @see UserInterface
  116.      */
  117.     public function eraseCredentials()
  118.     {
  119.         // If you store any temporary, sensitive data on the user, clear it here
  120.         // $this->plainPassword = null;
  121.     }
  122.     public function getNom(): ?string
  123.     {
  124.         return $this->nom;
  125.     }
  126.     public function setNom(string $nom): self
  127.     {
  128.         $this->nom $nom;
  129.         return $this;
  130.     }
  131.     public function getPrenoms(): ?string
  132.     {
  133.         return $this->prenoms;
  134.     }
  135.     public function setPrenoms(string $prenoms): self
  136.     {
  137.         $this->prenoms $prenoms;
  138.         return $this;
  139.     }
  140.     public function getEmail(): ?string
  141.     {
  142.         return $this->email;
  143.     }
  144.     public function setEmail(?string $email): self
  145.     {
  146.         $this->email $email;
  147.         return $this;
  148.     }
  149.     public function getBoutique(): ?string
  150.     {
  151.         return $this->boutique;
  152.     }
  153.     public function setBoutique(?string $boutique): self
  154.     {
  155.         $this->boutique $boutique;
  156.         return $this;
  157.     }
  158.     public function getVille(): ?string
  159.     {
  160.         return $this->ville;
  161.     }
  162.     public function setVille(Villes $ville): self
  163.     {
  164.         $this->ville $ville->getNom();
  165.         return $this;
  166.     }
  167.     public function getTelwhatsapp(): ?string
  168.     {
  169.         return $this->telwhatsapp;
  170.     }
  171.     public function setTelwhatsapp(?string $telwhatsapp): self
  172.     {
  173.         $this->telwhatsapp $telwhatsapp;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return Collection<int, Articles>
  178.      */
  179.     public function getArticles(): Collection
  180.     {
  181.         return $this->articles;
  182.     }
  183.     public function addArticle(Articles $article): self
  184.     {
  185.         if (!$this->articles->contains($article)) {
  186.             $this->articles[] = $article;
  187.             $article->setCreatedBy($this);
  188.         }
  189.         return $this;
  190.     }
  191.     public function removeArticle(Articles $article): self
  192.     {
  193.         if ($this->articles->removeElement($article)) {
  194.             // set the owning side to null (unless already changed)
  195.             if ($article->getCreatedBy() === $this) {
  196.                 $article->setCreatedBy(null);
  197.             }
  198.         }
  199.         return $this;
  200.     }
  201.     public function isIsVerified(): ?bool
  202.     {
  203.         return $this->isVerified;
  204.     }
  205.     public function setIsVerified(bool $isVerified): self
  206.     {
  207.         $this->isVerified $isVerified;
  208.         return $this;
  209.     }
  210.     public function getShop(): ?Boutiques
  211.     {
  212.         return $this->shop;
  213.     }
  214.     public function setShop(?Boutiques $shop): self
  215.     {
  216.         $this->shop $shop;
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return Collection<int, Immeubles>
  221.      */
  222.     public function getImmeubles(): Collection
  223.     {
  224.         return $this->immeubles;
  225.     }
  226.     public function addImmeuble(Immeubles $immeuble): self
  227.     {
  228.         if (!$this->immeubles->contains($immeuble)) {
  229.             $this->immeubles[] = $immeuble;
  230.             $immeuble->setVendeur($this);
  231.         }
  232.         return $this;
  233.     }
  234.     public function removeImmeuble(Immeubles $immeuble): self
  235.     {
  236.         if ($this->immeubles->removeElement($immeuble)) {
  237.             // set the owning side to null (unless already changed)
  238.             if ($immeuble->getVendeur() === $this) {
  239.                 $immeuble->setVendeur(null);
  240.             }
  241.         }
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection<int, Vehicules>
  246.      */
  247.     public function getVehicules(): Collection
  248.     {
  249.         return $this->vehicules;
  250.     }
  251.     public function addVehicule(Vehicules $vehicule): self
  252.     {
  253.         if (!$this->vehicules->contains($vehicule)) {
  254.             $this->vehicules[] = $vehicule;
  255.             $vehicule->setVendeur($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removeVehicule(Vehicules $vehicule): self
  260.     {
  261.         if ($this->vehicules->removeElement($vehicule)) {
  262.             // set the owning side to null (unless already changed)
  263.             if ($vehicule->getVendeur() === $this) {
  264.                 $vehicule->setVendeur(null);
  265.             }
  266.         }
  267.         return $this;
  268.     }
  269.     /**
  270.      * @return Collection<int, Favoris>
  271.      */
  272.     public function getFavoris(): Collection
  273.     {
  274.         return $this->favoris;
  275.     }
  276.     public function addFavori(Favoris $favori): self
  277.     {
  278.         if (!$this->favoris->contains($favori)) {
  279.             $this->favoris->add($favori);
  280.             $favori->setUtilisateur($this);
  281.         }
  282.         return $this;
  283.     }
  284.     public function removeFavori(Favoris $favori): self
  285.     {
  286.         if ($this->favoris->removeElement($favori)) {
  287.             // set the owning side to null (unless already changed)
  288.             if ($favori->getUtilisateur() === $this) {
  289.                 $favori->setUtilisateur(null);
  290.             }
  291.         }
  292.         return $this;
  293.     }
  294.     /**
  295.      * @return Collection<int, UserCode>
  296.      */
  297.     public function getUserCodes(): Collection
  298.     {
  299.         return $this->userCodes;
  300.     }
  301.     public function addUserCode(UserCode $userCode): static
  302.     {
  303.         if (!$this->userCodes->contains($userCode)) {
  304.             $this->userCodes->add($userCode);
  305.             $userCode->setUtilisateur($this);
  306.         }
  307.         return $this;
  308.     }
  309.     public function removeUserCode(UserCode $userCode): static
  310.     {
  311.         if ($this->userCodes->removeElement($userCode)) {
  312.             // set the owning side to null (unless already changed)
  313.             if ($userCode->getUtilisateur() === $this) {
  314.                 $userCode->setUtilisateur(null);
  315.             }
  316.         }
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Collection<int, Services>
  321.      */
  322.     public function getServices(): Collection
  323.     {
  324.         return $this->services;
  325.     }
  326.     public function addService(Services $service): static
  327.     {
  328.         if (!$this->services->contains($service)) {
  329.             $this->services->add($service);
  330.             $service->setCreatedBy($this);
  331.         }
  332.         return $this;
  333.     }
  334.     public function removeService(Services $service): static
  335.     {
  336.         if ($this->services->removeElement($service)) {
  337.             // set the owning side to null (unless already changed)
  338.             if ($service->getCreatedBy() === $this) {
  339.                 $service->setCreatedBy(null);
  340.             }
  341.         }
  342.         return $this;
  343.     }
  344. }