<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="Cet email est déjà associé à un compte")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $uuid;
/**
* @ORM\Column(type="string", length=180, unique=true, nullable=true)
*/
private ?string $email = null;
/**
* @ORM\Column(type="json")
*/
private array $roles = [];
public string $role;
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private ?string $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $nom;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $prenom;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $statut = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $activation;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?\DateTimeImmutable $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $token;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $online = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $loginAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $provider;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $sexe;
/**
* @ORM\OneToMany(targetEntity=Sujet::class, mappedBy="user")
*/
private $sujets;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="user")
*/
private $messages;
/**
* @ORM\OneToMany(targetEntity=Post::class, mappedBy="user")
*/
private $posts;
/**
* @ORM\OneToMany(targetEntity=Astuce::class, mappedBy="user")
*/
private $astuces;
/**
* @ORM\OneToMany(targetEntity=Droit::class, mappedBy="user")
*/
private $droits;
/**
* @ORM\OneToMany(targetEntity=Cv::class, mappedBy="user")
*/
private $cvs;
/**
* @ORM\OneToMany(targetEntity=Agora::class, mappedBy="user")
*/
private $agoras;
/**
* @ORM\OneToMany(targetEntity=Messagerie::class, mappedBy="emetteur")
*/
private $emetteur;
/**
* @ORM\OneToMany(targetEntity=Messagerie::class, mappedBy="destinataire")
*/
private $destinataire;
/**
* @ORM\OneToMany(targetEntity=Conversation::class, mappedBy="interlocuteur")
*/
private $conversations;
/**
* @ORM\OneToMany(targetEntity=Conversation::class, mappedBy="user")
*/
private $conversationsUser;
public function __construct()
{
$this->uuid = Uuid::v4();
$this->sujets = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->posts = new ArrayCollection();
$this->astuces = new ArrayCollection();
$this->droits = new ArrayCollection();
$this->cvs = new ArrayCollection();
$this->agoras = new ArrayCollection();
$this->emetteur = new ArrayCollection();
$this->destinataire = new ArrayCollection();
$this->conversations = new ArrayCollection();
$this->conversationsUser = new ArrayCollection();
}
/**
* getId
*
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* getUuid
*
* @return void
*/
public function getUuid()
{
return $this->uuid;
}
/**
* setUuid
*
* @param mixed $uuid
* @return self
*/
public function setUuid($uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* getEmail
*
* @return ?string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* setEmail
*
* @param mixed $email
* @return self
*/
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);
}
/**
* setRoles
*
* @param mixed $roles
* @return self
*/
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* setPassword
*
* @param mixed $password
* @return self
*/
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;
}
/**
* getNom
*
* @return string
*/
public function getNom(): ?string
{
return $this->nom;
}
/**
* setNom
*
* @param mixed $nom
* @return self
*/
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
/**
* getPrenom
*
* @return string
*/
public function getPrenom(): ?string
{
return $this->prenom;
}
/**
* setPrenom
*
* @param mixed $prenom
* @return self
*/
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
/**
* isStatut
*
* @return bool
*/
public function isStatut(): ?bool
{
return $this->statut;
}
/**
* setStatut
*
* @param mixed $statut
* @return self
*/
public function setStatut(?bool $statut): self
{
$this->statut = $statut;
return $this;
}
/**
* getActivation
*
* @return string
*/
public function getActivation(): ?string
{
return $this->activation;
}
/**
* setActivation
*
* @param mixed $activation
* @return self
*/
public function setActivation(?string $activation): self
{
$this->activation = $activation;
return $this;
}
/**
* getCreatedAt
*
* @return DateTimeImmutable
*/
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
/**
* setCreatedAt
*
* @param mixed $createdAt
* @return self
*/
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* getUpdatedAt
*
* @return DateTimeInterface
*/
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* setUpdatedAt
*
* @param mixed $updatedAt
* @return self
*/
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* getToken
*
* @return string
*/
public function getToken(): ?string
{
return $this->token;
}
/**
* setToken
*
* @param mixed $token
* @return self
*/
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
/**
* isOnline
*
* @return bool
*/
public function isOnline(): ?bool
{
return $this->online;
}
/**
* setOnline
*
* @param mixed $online
* @return self
*/
public function setOnline(?bool $online): self
{
$this->online = $online;
return $this;
}
/**
* getLoginAt
*
* @return DateTimeInterface
*/
public function getLoginAt(): ?\DateTimeInterface
{
return $this->loginAt;
}
/**
* setLoginAt
*
* @param mixed $loginAt
* @return self
*/
public function setLoginAt(?\DateTimeInterface $loginAt): self
{
$this->loginAt = $loginAt;
return $this;
}
/**
* getProvider
*
* @return string
*/
public function getProvider(): ?string
{
return $this->provider;
}
/**
* setProvider
*
* @param mixed $provider
* @return self
*/
public function setProvider(?string $provider): self
{
$this->provider = $provider;
return $this;
}
/**
* getSexe
*
* @return string
*/
public function getSexe(): ?string
{
return $this->sexe;
}
/**
* setSexe
*
* @param mixed $sexe
* @return self
*/
public function setSexe(?string $sexe): self
{
$this->sexe = $sexe;
return $this;
}
/**
* @return Collection<int, Sujet>
*/
public function getSujets(): Collection
{
return $this->sujets;
}
public function addSujet(Sujet $sujet): self
{
if (!$this->sujets->contains($sujet)) {
$this->sujets[] = $sujet;
$sujet->setUser($this);
}
return $this;
}
public function removeSujet(Sujet $sujet): self
{
if ($this->sujets->removeElement($sujet)) {
// set the owning side to null (unless already changed)
if ($sujet->getUser() === $this) {
$sujet->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Message>
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(Message $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setUser($this);
}
return $this;
}
public function removeMessage(Message $message): self
{
if ($this->messages->removeElement($message)) {
// set the owning side to null (unless already changed)
if ($message->getUser() === $this) {
$message->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Post>
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setUser($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->removeElement($post)) {
// set the owning side to null (unless already changed)
if ($post->getUser() === $this) {
$post->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Astuce>
*/
public function getAstuces(): Collection
{
return $this->astuces;
}
public function addAstuce(Astuce $astuce): self
{
if (!$this->astuces->contains($astuce)) {
$this->astuces[] = $astuce;
$astuce->setUser($this);
}
return $this;
}
public function removeAstuce(Astuce $astuce): self
{
if ($this->astuces->removeElement($astuce)) {
// set the owning side to null (unless already changed)
if ($astuce->getUser() === $this) {
$astuce->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Droit>
*/
public function getDroits(): Collection
{
return $this->droits;
}
public function addDroit(Droit $droit): self
{
if (!$this->droits->contains($droit)) {
$this->droits[] = $droit;
$droit->setUser($this);
}
return $this;
}
public function removeDroit(Droit $droit): self
{
if ($this->droits->removeElement($droit)) {
// set the owning side to null (unless already changed)
if ($droit->getUser() === $this) {
$droit->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Cv>
*/
public function getCvs(): Collection
{
return $this->cvs;
}
public function addCv(Cv $cv): self
{
if (!$this->cvs->contains($cv)) {
$this->cvs[] = $cv;
$cv->setUser($this);
}
return $this;
}
public function removeCv(Cv $cv): self
{
if ($this->cvs->removeElement($cv)) {
// set the owning side to null (unless already changed)
if ($cv->getUser() === $this) {
$cv->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Agora>
*/
public function getAgoras(): Collection
{
return $this->agoras;
}
public function addAgora(Agora $agora): self
{
if (!$this->agoras->contains($agora)) {
$this->agoras[] = $agora;
$agora->setUser($this);
}
return $this;
}
public function removeAgora(Agora $agora): self
{
if ($this->agoras->removeElement($agora)) {
// set the owning side to null (unless already changed)
if ($agora->getUser() === $this) {
$agora->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Messagerie>
*/
public function getEmetteur(): Collection
{
return $this->emetteur;
}
public function addEmetteur(Messagerie $emetteur): self
{
if (!$this->emetteur->contains($emetteur)) {
$this->emetteur[] = $emetteur;
$emetteur->setEmetteur($this);
}
return $this;
}
public function removeEmetteur(Messagerie $emetteur): self
{
if ($this->emetteur->removeElement($emetteur)) {
// set the owning side to null (unless already changed)
if ($emetteur->getEmetteur() === $this) {
$emetteur->setEmetteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Messagerie>
*/
public function getDestinataire(): Collection
{
return $this->destinataire;
}
public function addDestinataire(Messagerie $destinataire): self
{
if (!$this->destinataire->contains($destinataire)) {
$this->destinataire[] = $destinataire;
$destinataire->setDestinataire($this);
}
return $this;
}
public function removeDestinataire(Messagerie $destinataire): self
{
if ($this->destinataire->removeElement($destinataire)) {
// set the owning side to null (unless already changed)
if ($destinataire->getDestinataire() === $this) {
$destinataire->setDestinataire(null);
}
}
return $this;
}
/**
* @return Collection<int, Conversation>
*/
public function getConversations(): Collection
{
return $this->conversations;
}
public function addConversation(Conversation $conversation): self
{
if (!$this->conversations->contains($conversation)) {
$this->conversations[] = $conversation;
$conversation->setInterlocuteur($this);
}
return $this;
}
public function removeConversation(Conversation $conversation): self
{
if ($this->conversations->removeElement($conversation)) {
// set the owning side to null (unless already changed)
if ($conversation->getInterlocuteur() === $this) {
$conversation->setInterlocuteur(null);
}
}
return $this;
}
/**
* @return Collection<int, Conversation>
*/
public function getConversationsUser(): Collection
{
return $this->conversationsUser;
}
public function addConversationsUser(Conversation $conversationsUser): self
{
if (!$this->conversationsUser->contains($conversationsUser)) {
$this->conversationsUser[] = $conversationsUser;
$conversationsUser->setUser($this);
}
return $this;
}
public function removeConversationsUser(Conversation $conversationsUser): self
{
if ($this->conversationsUser->removeElement($conversationsUser)) {
// set the owning side to null (unless already changed)
if ($conversationsUser->getUser() === $this) {
$conversationsUser->setUser(null);
}
}
return $this;
}
}