<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\Ficherdate;
use App\Repository\ClientUserRepository;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=ClientUserRepository::class)
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
* @ORM\HasLifecycleCallbacks
*/
class ClientUser 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="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $prenom;
/**
* @ORM\Column(type="string", length=255)
*/
private $numero;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\Column(type="string", length=255)
*/
private $compte;
/**
* @ORM\OneToMany(targetEntity=Livraison::class, mappedBy="userClient", orphanRemoval=true)
*/
private $livraisons;
/**
* @ORM\OneToMany(targetEntity=Suivre::class, mappedBy="userClient", orphanRemoval=true)
*/
private $suivres;
public function __construct()
{
$this->livraisons = new ArrayCollection();
$this->suivres = new ArrayCollection();
$this->couvertureProfils = 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 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 getNumero(): ?string
{
return $this->numero;
}
public function setNumero(string $numero): self
{
$this->numero = $numero;
return $this;
}
public function getToutleNom(): string
{
return $this->getNom() . ' ' . $this->getPrenom();
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
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->setUserClient($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->getUserClient() === $this) {
$livraison->setUserClient(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->setUserClient($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->getUserClient() === $this) {
$suivre->setUserClient(null);
}
}
return $this;
}
}