src/Entity/UserVendeur.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserVendeurRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\Ficherdate;
  8. use App\Entity\ClientUser;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. /**
  13.  * @ORM\Entity(repositoryClass=UserVendeurRepository::class)
  14.  * @UniqueEntity(fields={"email"}, message="un compte existe déjà avec cet e-mail")
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class UserVendeur implements UserInterfacePasswordAuthenticatedUserInterface
  18. {
  19.     use Ficherdate;
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=180, unique=true)
  28.      */
  29.     private $email;
  30.     /**
  31.      * @ORM\Column(type="json")
  32.      */
  33.     private $roles = [];
  34.     /**
  35.      * @var string The hashed password
  36.      * @ORM\Column(type="string")
  37.      */
  38.     private $password;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $isVerified false;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $nom;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private $prenom;
  51.     /**
  52.      * @ORM\Column(type="string", length=255)
  53.      */
  54.     private $nomBoutique;
  55.     /**
  56.      * @ORM\Column(type="string", length=255)
  57.      */
  58.     private $categorie;
  59.     /**
  60.      * @ORM\Column(type="string", length=255)
  61.      */
  62.     private $numero;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $description;
  67.     /**
  68.      * @ORM\Column(type="string", length=255)
  69.      */
  70.     private $geolocalisation;
  71.     /**
  72.      * @ORM\Column(type="string", length=255)
  73.      */
  74.     private $compte;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity=Livraison::class, mappedBy="userVendeur", orphanRemoval=true)
  77.      */
  78.     private $livraisons;
  79.     /**
  80.      * @ORM\OneToMany(targetEntity=Suivre::class, mappedBy="userVendeur", orphanRemoval=true)
  81.      */
  82.     private $suivres;
  83.     /**
  84.      * @ORM\OneToMany(targetEntity=Articles::class, mappedBy="vendeurs", orphanRemoval=true)
  85.      */
  86.     private $articles;
  87.     /**
  88.      * @ORM\OneToMany(targetEntity=CouvertureProfil::class, mappedBy="vendeurs")
  89.      */
  90.     private $couvertureProfils;
  91.     /**
  92.      * @ORM\OneToMany(targetEntity=PhotoVendeurs::class, mappedBy="vendeurs", orphanRemoval=true)
  93.      */
  94.     private $photoVendeurs;
  95.     public function __construct()
  96.     {
  97.         $this->livraisons = new ArrayCollection();
  98.         $this->suivres = new ArrayCollection();
  99.         $this->articles = new ArrayCollection();
  100.         $this->couvertureProfils = new ArrayCollection();
  101.         $this->photoVendeurs = new ArrayCollection();
  102.     }
  103.     
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getEmail(): ?string
  109.     {
  110.         return $this->email;
  111.     }
  112.     public function setEmail(string $email): self
  113.     {
  114.         $this->email $email;
  115.         return $this;
  116.     }
  117.     /**
  118.      * A visual identifier that represents this user.
  119.      *
  120.      * @see UserInterface
  121.      */
  122.     public function getUserIdentifier(): string
  123.     {
  124.         return (string) $this->email;
  125.     }
  126.     /**
  127.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  128.      */
  129.     public function getUsername(): string
  130.     {
  131.         return (string) $this->email;
  132.     }
  133.     /**
  134.      * @see UserInterface
  135.      */
  136.     public function getRoles(): array
  137.     {
  138.         $roles $this->roles;
  139.         // guarantee every user at least has ROLE_USER
  140.         $roles[] = 'ROLE_USER';
  141.         return array_unique($roles);
  142.     }
  143.     public function setRoles(array $roles): self
  144.     {
  145.         $this->roles $roles;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @see PasswordAuthenticatedUserInterface
  150.      */
  151.     public function getPassword(): string
  152.     {
  153.         return $this->password;
  154.     }
  155.     public function setPassword(string $password): self
  156.     {
  157.         $this->password $password;
  158.         return $this;
  159.     }
  160.     /**
  161.      * Returning a salt is only needed, if you are not using a modern
  162.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  163.      *
  164.      * @see UserInterface
  165.      */
  166.     public function getSalt(): ?string
  167.     {
  168.         return null;
  169.     }
  170.     /**
  171.      * @see UserInterface
  172.      */
  173.     public function eraseCredentials()
  174.     {
  175.         // If you store any temporary, sensitive data on the user, clear it here
  176.         // $this->plainPassword = null;
  177.     }
  178.     public function isVerified(): bool
  179.     {
  180.         return $this->isVerified;
  181.     }
  182.     public function setIsVerified(bool $isVerified): self
  183.     {
  184.         $this->isVerified $isVerified;
  185.         return $this;
  186.     }
  187.     public function getNom(): ?string
  188.     {
  189.         return $this->nom;
  190.     }
  191.     public function setNom(string $nom): self
  192.     {
  193.         $this->nom $nom;
  194.         return $this;
  195.     }
  196.     public function getPrenom(): ?string
  197.     {
  198.         return $this->prenom;
  199.     }
  200.     public function setPrenom(string $prenom): self
  201.     {
  202.         $this->prenom $prenom;
  203.         return $this;
  204.     }
  205.     public function getToutleNom(): string
  206.     {
  207.         return $this->getNom() . ' ' $this->getPrenom();
  208.     }
  209.     public function getNomBoutique(): ?string
  210.     {
  211.         return $this->nomBoutique;
  212.     }
  213.     public function setNomBoutique(string $nomBoutique): self
  214.     {
  215.         $this->nomBoutique $nomBoutique;
  216.         return $this;
  217.     }
  218.     public function getCategorie(): ?string
  219.     {
  220.         return $this->categorie;
  221.     }
  222.     public function setCategorie(string $categorie): self
  223.     {
  224.         $this->categorie $categorie;
  225.         return $this;
  226.     }
  227.     public function getNumero(): ?int
  228.     {
  229.         return $this->numero;
  230.     }
  231.     public function setNumero(int $numero): self
  232.     {
  233.         $this->numero $numero;
  234.         return $this;
  235.     }
  236.     public function getDescription(): ?string
  237.     {
  238.         return $this->description;
  239.     }
  240.     public function setDescription(?string $description): self
  241.     {
  242.         $this->description $description;
  243.         return $this;
  244.     }
  245.     public function getGeolocalisation(): ?string
  246.     {
  247.         return $this->geolocalisation;
  248.     }
  249.     public function setGeolocalisation(string $geolocalisation): self
  250.     {
  251.         $this->geolocalisation $geolocalisation;
  252.         return $this;
  253.     }
  254.     public function getCompte(): ?string
  255.     {
  256.         return $this->compte;
  257.     }
  258.     public function setCompte(string $compte): self
  259.     {
  260.         $this->compte $compte;
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection<int, Livraison>
  265.      */
  266.     public function getLivraisons(): Collection
  267.     {
  268.         return $this->livraisons;
  269.     }
  270.     public function addLivraison(Livraison $livraison): self
  271.     {
  272.         if (!$this->livraisons->contains($livraison)) {
  273.             $this->livraisons[] = $livraison;
  274.             $livraison->setUserVendeur($this);
  275.         }
  276.         return $this;
  277.     }
  278.     public function removeLivraison(Livraison $livraison): self
  279.     {
  280.         if ($this->livraisons->removeElement($livraison)) {
  281.             // set the owning side to null (unless already changed)
  282.             if ($livraison->getUserVendeur() === $this) {
  283.                 $livraison->setUserVendeur(null);
  284.             }
  285.         }
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return Collection<int, Suivre>
  290.      */
  291.     public function getSuivres(): Collection
  292.     {
  293.         return $this->suivres;
  294.     }
  295.     public function addSuivre(Suivre $suivre): self
  296.     {
  297.         if (!$this->suivres->contains($suivre)) {
  298.             $this->suivres[] = $suivre;
  299.             $suivre->setUserVendeur($this);
  300.         }
  301.         return $this;
  302.     }
  303.     public function removeSuivre(Suivre $suivre): self
  304.     {
  305.         if ($this->suivres->removeElement($suivre)) {
  306.             // set the owning side to null (unless already changed)
  307.             if ($suivre->getUserVendeur() === $this) {
  308.                 $suivre->setUserVendeur(null);
  309.             }
  310.         }
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection<int, Articles>
  315.      */
  316.     public function getArticles(): Collection
  317.     {
  318.         return $this->articles;
  319.     }
  320.     public function addArticle(Articles $article): self
  321.     {
  322.         if (!$this->articles->contains($article)) {
  323.             $this->articles[] = $article;
  324.             $article->setVendeurs($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeArticle(Articles $article): self
  329.     {
  330.         if ($this->articles->removeElement($article)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($article->getVendeurs() === $this) {
  333.                 $article->setVendeurs(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     /**
  339.      * cette fonction permet de voir si une boutique est abonné à une boutique
  340.      * 
  341.      * @param UserVendeur $userVendeur
  342.      * @return boolean
  343.      */
  344.     public function BoutiqueAbonneAboutique(ClientUser $userUser): bool 
  345.     {
  346.         foreach ($this->suivres as $suivres) {
  347.             
  348.             if ($suivres->getUserClient() == $userUser) return true;
  349.         }
  350.         return false;
  351.         
  352.     }
  353.     /**
  354.      * @return Collection<int, CouvertureProfil>
  355.      */
  356.     public function getCouvertureProfils(): Collection
  357.     {
  358.         return $this->couvertureProfils;
  359.     }
  360.     public function addCouvertureProfil(CouvertureProfil $couvertureProfil): self
  361.     {
  362.         if (!$this->couvertureProfils->contains($couvertureProfil)) {
  363.             $this->couvertureProfils[] = $couvertureProfil;
  364.             $couvertureProfil->setVendeurs($this);
  365.         }
  366.         return $this;
  367.     }
  368.     public function removeCouvertureProfil(CouvertureProfil $couvertureProfil): self
  369.     {
  370.         if ($this->couvertureProfils->removeElement($couvertureProfil)) {
  371.             // set the owning side to null (unless already changed)
  372.             if ($couvertureProfil->getVendeurs() === $this) {
  373.                 $couvertureProfil->setVendeurs(null);
  374.             }
  375.         }
  376.         return $this;
  377.     }
  378.     /**
  379.      * @return Collection<int, PhotoVendeurs>
  380.      */
  381.     public function getPhotoVendeurs(): Collection
  382.     {
  383.         return $this->photoVendeurs;
  384.     }
  385.     public function addPhotoVendeur(PhotoVendeurs $photoVendeur): self
  386.     {
  387.         if (!$this->photoVendeurs->contains($photoVendeur)) {
  388.             $this->photoVendeurs[] = $photoVendeur;
  389.             $photoVendeur->setVendeurs($this);
  390.         }
  391.         return $this;
  392.     }
  393.     public function removePhotoVendeur(PhotoVendeurs $photoVendeur): self
  394.     {
  395.         if ($this->photoVendeurs->removeElement($photoVendeur)) {
  396.             // set the owning side to null (unless already changed)
  397.             if ($photoVendeur->getVendeurs() === $this) {
  398.                 $photoVendeur->setVendeurs(null);
  399.             }
  400.         }
  401.         return $this;
  402.     }
  403.     
  404. }