<?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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
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: 'string', length: 255, nullable: true)]
private $nom;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $prenom;
#[ORM\ManyToOne(targetEntity: Agence::class, inversedBy: 'users', cascade: ['persist'])]
private $agence;
#[ORM\OneToMany(targetEntity: Proposition::class, mappedBy: 'auteur', cascade: ['persist'])]
private $propositions;
#[ORM\OneToMany(targetEntity: Dossier::class, mappedBy: 'auteur', cascade: ['persist'])]
private $dossiersAuteur;
#[ORM\OneToMany(targetEntity: Dossier::class, mappedBy: 'relecteur', cascade: ['persist'])]
private $dossiersRelecteur;
#[ORM\OneToMany(targetEntity: Dossier::class, mappedBy: 'validateur', cascade: ['persist'])]
private $dossiersValidateur;
#[ORM\OneToMany(targetEntity: Courrier::class, mappedBy: 'auteur', cascade: ['persist'])]
private $courriers;
#[ORM\OneToMany(targetEntity: Affaire::class, mappedBy: 'responsable', cascade: ['persist'])]
private $affaires;
#[ORM\Column(type: 'datetime', nullable: true)]
private $createdAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updatedAt;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $telephone;
#[ORM\Column(type: 'boolean', nullable: true)]
private $actif = true;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $trigramme;
public function __toString()
{
$trigramme=$this->getTrigramme();
if(!$trigramme){ $trigramme="non défini";}
return $trigramme;
}
public function __construct()
{
$this->setRoles(["ROLE_USER"]);
$this->propositions = new ArrayCollection();
$this->dossiersAuteur = new ArrayCollection();
$this->dossiersRelecteur = new ArrayCollection();
$this->dossiersValidateur = new ArrayCollection();
$this->courriers = new ArrayCollection();
$this->affaires = 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;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
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 UserInterface
*/
public function getPassword(): string
{
return (string) $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 getAgence(): ?Agence
{
return $this->agence;
}
public function setAgence(?Agence $agence): self
{
$this->agence = $agence;
return $this;
}
/**
* @return Collection|Proposition[]
*/
public function getPropositions(): Collection
{
return $this->propositions;
}
public function addProposition(Proposition $proposition): self
{
if (!$this->propositions->contains($proposition)) {
$this->propositions[] = $proposition;
$proposition->setAuteur($this);
}
return $this;
}
public function removeProposition(Proposition $proposition): self
{
if ($this->propositions->removeElement($proposition)) {
// set the owning side to null (unless already changed)
if ($proposition->getAuteur() === $this) {
$proposition->setAuteur(null);
}
}
return $this;
}
/**
* @return Collection|Dossier[]
*/
public function getDossiersAuteur(): Collection
{
return $this->dossiersAuteur;
}
public function addDossiersAuteur(Dossier $dossiersAuteur): self
{
if (!$this->dossiersAuteur->contains($dossiersAuteur)) {
$this->dossiersAuteur[] = $dossiersAuteur;
$dossiersAuteur->setAuteur($this);
}
return $this;
}
public function removeDossiersAuteur(Dossier $dossiersAuteur): self
{
if ($this->dossiersAuteur->removeElement($dossiersAuteur)) {
// set the owning side to null (unless already changed)
if ($dossiersAuteur->getAuteur() === $this) {
$dossiersAuteur->setAuteur(null);
}
}
return $this;
}
/**
* @return Collection|Dossier[]
*/
public function getDossiersRelecteur(): Collection
{
return $this->dossiersRelecteur;
}
public function addDossiersRelecteur(Dossier $dossiersRelecteur): self
{
if (!$this->dossiersRelecteur->contains($dossiersRelecteur)) {
$this->dossiersRelecteur[] = $dossiersRelecteur;
$dossiersRelecteur->setRelecteur($this);
}
return $this;
}
public function removeDossiersRelecteur(Dossier $dossiersRelecteur): self
{
if ($this->dossiersRelecteur->removeElement($dossiersRelecteur)) {
// set the owning side to null (unless already changed)
if ($dossiersRelecteur->getRelecteur() === $this) {
$dossiersRelecteur->setRelecteur(null);
}
}
return $this;
}
/**
* @return Collection|Dossier[]
*/
public function getDossiersValidateur(): Collection
{
return $this->dossiersValidateur;
}
public function addDossiersValidateur(Dossier $dossiersValidateur): self
{
if (!$this->dossiersValidateur->contains($dossiersValidateur)) {
$this->dossiersValidateur[] = $dossiersValidateur;
$dossiersValidateur->setValidateur($this);
}
return $this;
}
public function removeDossiersValidateur(Dossier $dossiersValidateur): self
{
if ($this->dossiersValidateur->removeElement($dossiersValidateur)) {
// set the owning side to null (unless already changed)
if ($dossiersValidateur->getValidateur() === $this) {
$dossiersValidateur->setValidateur(null);
}
}
return $this;
}
/**
* @return Collection|Courrier[]
*/
public function getCourriers(): Collection
{
return $this->courriers;
}
public function addCourrier(Courrier $courrier): self
{
if (!$this->courriers->contains($courrier)) {
$this->courriers[] = $courrier;
$courrier->setAuteur($this);
}
return $this;
}
public function removeCourrier(Courrier $courrier): self
{
if ($this->courriers->removeElement($courrier)) {
// set the owning side to null (unless already changed)
if ($courrier->getAuteur() === $this) {
$courrier->setAuteur(null);
}
}
return $this;
}
/**
* @return Collection|Affaire[]
*/
public function getAffaires(): Collection
{
return $this->affaires;
}
public function addAffaire(Affaire $affaire): self
{
if (!$this->affaires->contains($affaire)) {
$this->affaires[] = $affaire;
$affaire->setResponsable($this);
}
return $this;
}
public function removeAffaire(Affaire $affaire): self
{
if ($this->affaires->removeElement($affaire)) {
// set the owning side to null (unless already changed)
if ($affaire->getResponsable() === $this) {
$affaire->setResponsable(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
private $plainPassword = null;
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
public function setPlainPassword(string $password): void
{
$this->plainPassword = $password;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(?string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(?bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getTrigramme(): ?string
{
return $this->trigramme;
}
public function setTrigramme(?string $trigramme): self
{
$this->trigramme = $trigramme;
return $this;
}
}