<?php
namespace App\Entity;
use App\Repository\UserVendeurRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\Ficherdate;
use App\Entity\ClientUser;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserVendeurRepository::class)
* @UniqueEntity(fields={"email"}, message="un compte existe déjà avec cet e-mail")
* @ORM\HasLifecycleCallbacks
*/
class UserVendeur implements UserInterface, PasswordAuthenticatedUserInterface
{
use Ficherdate;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $prenom;
/**
* @ORM\Column(type="string", length=255)
*/
private $nomBoutique;
/**
* @ORM\Column(type="string", length=255)
*/
private $categorie;
/**
* @ORM\Column(type="string", length=255)
*/
private $numero;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255)
*/
private $geolocalisation;
/**
* @ORM\Column(type="string", length=255)
*/
private $compte;
/**
* @ORM\OneToMany(targetEntity=Livraison::class, mappedBy="userVendeur", orphanRemoval=true)
*/
private $livraisons;
/**
* @ORM\OneToMany(targetEntity=Suivre::class, mappedBy="userVendeur", orphanRemoval=true)
*/
private $suivres;
/**
* @ORM\OneToMany(targetEntity=Articles::class, mappedBy="vendeurs", orphanRemoval=true)
*/
private $articles;
/**
* @ORM\OneToMany(targetEntity=CouvertureProfil::class, mappedBy="vendeurs")
*/
private $couvertureProfils;
/**
* @ORM\OneToMany(targetEntity=PhotoVendeurs::class, mappedBy="vendeurs", orphanRemoval=true)
*/
private $photoVendeurs;
public function __construct()
{
$this->livraisons = new ArrayCollection();
$this->suivres = new ArrayCollection();
$this->articles = new ArrayCollection();
$this->couvertureProfils = new ArrayCollection();
$this->photoVendeurs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getToutleNom(): string
{
return $this->getNom() . ' ' . $this->getPrenom();
}
public function getNomBoutique(): ?string
{
return $this->nomBoutique;
}
public function setNomBoutique(string $nomBoutique): self
{
$this->nomBoutique = $nomBoutique;
return $this;
}
public function getCategorie(): ?string
{
return $this->categorie;
}
public function setCategorie(string $categorie): self
{
$this->categorie = $categorie;
return $this;
}
public function getNumero(): ?int
{
return $this->numero;
}
public function setNumero(int $numero): self
{
$this->numero = $numero;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getGeolocalisation(): ?string
{
return $this->geolocalisation;
}
public function setGeolocalisation(string $geolocalisation): self
{
$this->geolocalisation = $geolocalisation;
return $this;
}
public function getCompte(): ?string
{
return $this->compte;
}
public function setCompte(string $compte): self
{
$this->compte = $compte;
return $this;
}
/**
* @return Collection<int, Livraison>
*/
public function getLivraisons(): Collection
{
return $this->livraisons;
}
public function addLivraison(Livraison $livraison): self
{
if (!$this->livraisons->contains($livraison)) {
$this->livraisons[] = $livraison;
$livraison->setUserVendeur($this);
}
return $this;
}
public function removeLivraison(Livraison $livraison): self
{
if ($this->livraisons->removeElement($livraison)) {
// set the owning side to null (unless already changed)
if ($livraison->getUserVendeur() === $this) {
$livraison->setUserVendeur(null);
}
}
return $this;
}
/**
* @return Collection<int, Suivre>
*/
public function getSuivres(): Collection
{
return $this->suivres;
}
public function addSuivre(Suivre $suivre): self
{
if (!$this->suivres->contains($suivre)) {
$this->suivres[] = $suivre;
$suivre->setUserVendeur($this);
}
return $this;
}
public function removeSuivre(Suivre $suivre): self
{
if ($this->suivres->removeElement($suivre)) {
// set the owning side to null (unless already changed)
if ($suivre->getUserVendeur() === $this) {
$suivre->setUserVendeur(null);
}
}
return $this;
}
/**
* @return Collection<int, Articles>
*/
public function getArticles(): Collection
{
return $this->articles;
}
public function addArticle(Articles $article): self
{
if (!$this->articles->contains($article)) {
$this->articles[] = $article;
$article->setVendeurs($this);
}
return $this;
}
public function removeArticle(Articles $article): self
{
if ($this->articles->removeElement($article)) {
// set the owning side to null (unless already changed)
if ($article->getVendeurs() === $this) {
$article->setVendeurs(null);
}
}
return $this;
}
/**
* cette fonction permet de voir si une boutique est abonné à une boutique
*
* @param UserVendeur $userVendeur
* @return boolean
*/
public function BoutiqueAbonneAboutique(ClientUser $userUser): bool
{
foreach ($this->suivres as $suivres) {
if ($suivres->getUserClient() == $userUser) return true;
}
return false;
}
/**
* @return Collection<int, CouvertureProfil>
*/
public function getCouvertureProfils(): Collection
{
return $this->couvertureProfils;
}
public function addCouvertureProfil(CouvertureProfil $couvertureProfil): self
{
if (!$this->couvertureProfils->contains($couvertureProfil)) {
$this->couvertureProfils[] = $couvertureProfil;
$couvertureProfil->setVendeurs($this);
}
return $this;
}
public function removeCouvertureProfil(CouvertureProfil $couvertureProfil): self
{
if ($this->couvertureProfils->removeElement($couvertureProfil)) {
// set the owning side to null (unless already changed)
if ($couvertureProfil->getVendeurs() === $this) {
$couvertureProfil->setVendeurs(null);
}
}
return $this;
}
/**
* @return Collection<int, PhotoVendeurs>
*/
public function getPhotoVendeurs(): Collection
{
return $this->photoVendeurs;
}
public function addPhotoVendeur(PhotoVendeurs $photoVendeur): self
{
if (!$this->photoVendeurs->contains($photoVendeur)) {
$this->photoVendeurs[] = $photoVendeur;
$photoVendeur->setVendeurs($this);
}
return $this;
}
public function removePhotoVendeur(PhotoVendeurs $photoVendeur): self
{
if ($this->photoVendeurs->removeElement($photoVendeur)) {
// set the owning side to null (unless already changed)
if ($photoVendeur->getVendeurs() === $this) {
$photoVendeur->setVendeurs(null);
}
}
return $this;
}
}