<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @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\OneToOne(targetEntity=Installateur::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $installateur;
/**
* @ORM\OneToOne(targetEntity=Obliges::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $obliges;
/**
* @ORM\OneToOne(targetEntity=Equipe::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $equipe;
/**
* @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="user_id")
*/
private $notifications;
/**
* @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="sender")
*/
private $sendernotif;
/**
* @ORM\OneToMany(targetEntity=Tokenpassword::class, mappedBy="user")
*/
private $tokenpasswords;
/**
* @ORM\OneToMany(targetEntity=HistoriqueDeal::class, mappedBy="user")
*/
private $historiqueDeals;
/**
* @ORM\OneToMany(targetEntity=CommentaireDeal::class, mappedBy="user")
*/
private $commentaireDeals;
/**
* @ORM\OneToMany(targetEntity=CommentaireInstalleur::class, mappedBy="user")
*/
private $commentaireInstalleurs;
/**
* @ORM\OneToMany(targetEntity=Filtre::class, mappedBy="user")
*/
private $filtres;
/**
* @ORM\OneToMany(targetEntity=CommentaireContrat::class, mappedBy="user")
*/
private $commentaireContrats;
/**
* @ORM\OneToMany(targetEntity=CommentaireFactureaaf::class, mappedBy="user")
*/
private $commentaireFactureaafs;
/**
* @ORM\OneToMany(targetEntity=CommentaireAppelqualite::class, mappedBy="user")
*/
private $commentaireAppelqualites;
public function __construct()
{
$this->notifications = new ArrayCollection();
$this->sendernotif = new ArrayCollection();
$this->tokenpasswords = new ArrayCollection();
$this->historiqueDeals = new ArrayCollection();
$this->commentaireDeals = new ArrayCollection();
$this->commentaireInstalleurs = new ArrayCollection();
$this->filtres = new ArrayCollection();
$this->commentaireContrats = new ArrayCollection();
$this->commentaireFactureaafs = new ArrayCollection();
$this->commentaireAppelqualites = 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 getInstallateur(): ?Installateur
{
return $this->installateur;
}
public function setInstallateur(?Installateur $installateur): self
{
// unset the owning side of the relation if necessary
if ($installateur === null && $this->installateur !== null) {
$this->installateur->setUser(null);
}
// set the owning side of the relation if necessary
if ($installateur !== null && $installateur->getUser() !== $this) {
$installateur->setUser($this);
}
$this->installateur = $installateur;
return $this;
}
public function getObliges(): ?Obliges
{
return $this->obliges;
}
public function setObliges(?Obliges $obliges): self
{
// unset the owning side of the relation if necessary
if ($obliges === null && $this->obliges !== null) {
$this->obliges->setUser(null);
}
// set the owning side of the relation if necessary
if ($obliges !== null && $obliges->getUser() !== $this) {
$obliges->setUser($this);
}
$this->obliges = $obliges;
return $this;
}
public function getEquipe(): ?Equipe
{
return $this->equipe;
}
public function setEquipe(?Equipe $equipe): self
{
// unset the owning side of the relation if necessary
if ($equipe === null && $this->equipe !== null) {
$this->equipe->setUser(null);
}
// set the owning side of the relation if necessary
if ($equipe !== null && $equipe->getUser() !== $this) {
$equipe->setUser($this);
}
$this->equipe = $equipe;
return $this;
}
/**
* @return Collection<int, Notifications>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notifications $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUserId($this);
}
return $this;
}
public function removeNotification(Notifications $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUserId() === $this) {
$notification->setUserId(null);
}
}
return $this;
}
/**
* @return Collection<int, Notifications>
*/
public function getSendernotif(): Collection
{
return $this->sendernotif;
}
public function addSendernotif(Notifications $sendernotif): self
{
if (!$this->sendernotif->contains($sendernotif)) {
$this->sendernotif[] = $sendernotif;
$sendernotif->setSender($this);
}
return $this;
}
public function removeSendernotif(Notifications $sendernotif): self
{
if ($this->sendernotif->removeElement($sendernotif)) {
// set the owning side to null (unless already changed)
if ($sendernotif->getSender() === $this) {
$sendernotif->setSender(null);
}
}
return $this;
}
/**
* @return Collection<int, Tokenpassword>
*/
public function getTokenpasswords(): Collection
{
return $this->tokenpasswords;
}
public function addTokenpassword(Tokenpassword $tokenpassword): self
{
if (!$this->tokenpasswords->contains($tokenpassword)) {
$this->tokenpasswords[] = $tokenpassword;
$tokenpassword->setUser($this);
}
return $this;
}
public function removeTokenpassword(Tokenpassword $tokenpassword): self
{
if ($this->tokenpasswords->removeElement($tokenpassword)) {
// set the owning side to null (unless already changed)
if ($tokenpassword->getUser() === $this) {
$tokenpassword->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, HistoriqueDeal>
*/
public function getHistoriqueDeals(): Collection
{
return $this->historiqueDeals;
}
public function addHistoriqueDeal(HistoriqueDeal $historiqueDeal): self
{
if (!$this->historiqueDeals->contains($historiqueDeal)) {
$this->historiqueDeals[] = $historiqueDeal;
$historiqueDeal->setUser($this);
}
return $this;
}
public function removeHistoriqueDeal(HistoriqueDeal $historiqueDeal): self
{
if ($this->historiqueDeals->removeElement($historiqueDeal)) {
// set the owning side to null (unless already changed)
if ($historiqueDeal->getUser() === $this) {
$historiqueDeal->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentaireDeal>
*/
public function getCommentaireDeals(): Collection
{
return $this->commentaireDeals;
}
public function addCommentaireDeal(CommentaireDeal $commentaireDeal): self
{
if (!$this->commentaireDeals->contains($commentaireDeal)) {
$this->commentaireDeals[] = $commentaireDeal;
$commentaireDeal->setUser($this);
}
return $this;
}
public function removeCommentaireDeal(CommentaireDeal $commentaireDeal): self
{
if ($this->commentaireDeals->removeElement($commentaireDeal)) {
// set the owning side to null (unless already changed)
if ($commentaireDeal->getUser() === $this) {
$commentaireDeal->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentaireInstalleur>
*/
public function getCommentaireInstalleurs(): Collection
{
return $this->commentaireInstalleurs;
}
public function addCommentaireInstalleur(CommentaireInstalleur $commentaireInstalleur): self
{
if (!$this->commentaireInstalleurs->contains($commentaireInstalleur)) {
$this->commentaireInstalleurs[] = $commentaireInstalleur;
$commentaireInstalleur->setUser($this);
}
return $this;
}
public function removeCommentaireInstalleur(CommentaireInstalleur $commentaireInstalleur): self
{
if ($this->commentaireInstalleurs->removeElement($commentaireInstalleur)) {
// set the owning side to null (unless already changed)
if ($commentaireInstalleur->getUser() === $this) {
$commentaireInstalleur->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Filtre>
*/
public function getFiltres(): Collection
{
return $this->filtres;
}
public function addFiltre(Filtre $filtre): self
{
if (!$this->filtres->contains($filtre)) {
$this->filtres[] = $filtre;
$filtre->setUser($this);
}
return $this;
}
public function removeFiltre(Filtre $filtre): self
{
if ($this->filtres->removeElement($filtre)) {
// set the owning side to null (unless already changed)
if ($filtre->getUser() === $this) {
$filtre->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentaireContrat>
*/
public function getCommentaireContrats(): Collection
{
return $this->commentaireContrats;
}
public function addCommentaireContrat(CommentaireContrat $commentaireContrat): self
{
if (!$this->commentaireContrats->contains($commentaireContrat)) {
$this->commentaireContrats[] = $commentaireContrat;
$commentaireContrat->setUser($this);
}
return $this;
}
public function removeCommentaireContrat(CommentaireContrat $commentaireContrat): self
{
if ($this->commentaireContrats->removeElement($commentaireContrat)) {
// set the owning side to null (unless already changed)
if ($commentaireContrat->getUser() === $this) {
$commentaireContrat->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentaireFactureaaf>
*/
public function getCommentaireFactureaafs(): Collection
{
return $this->commentaireFactureaafs;
}
public function addCommentaireFactureaaf(CommentaireFactureaaf $commentaireFactureaaf): self
{
if (!$this->commentaireFactureaafs->contains($commentaireFactureaaf)) {
$this->commentaireFactureaafs[] = $commentaireFactureaaf;
$commentaireFactureaaf->setUser($this);
}
return $this;
}
public function removeCommentaireFactureaaf(CommentaireFactureaaf $commentaireFactureaaf): self
{
if ($this->commentaireFactureaafs->removeElement($commentaireFactureaaf)) {
// set the owning side to null (unless already changed)
if ($commentaireFactureaaf->getUser() === $this) {
$commentaireFactureaaf->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentaireAppelqualite>
*/
public function getCommentaireAppelqualites(): Collection
{
return $this->commentaireAppelqualites;
}
public function addCommentaireAppelqualite(CommentaireAppelqualite $commentaireAppelqualite): self
{
if (!$this->commentaireAppelqualites->contains($commentaireAppelqualite)) {
$this->commentaireAppelqualites[] = $commentaireAppelqualite;
$commentaireAppelqualite->setUser($this);
}
return $this;
}
public function removeCommentaireAppelqualite(CommentaireAppelqualite $commentaireAppelqualite): self
{
if ($this->commentaireAppelqualites->removeElement($commentaireAppelqualite)) {
// set the owning side to null (unless already changed)
if ($commentaireAppelqualite->getUser() === $this) {
$commentaireAppelqualite->setUser(null);
}
}
return $this;
}
}