<?php
namespace App\Entity;
use App\Repository\UserRepository;
use DateInterval;
use DateTime;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use PhpParser\Node\Expr\FuncCall;
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)]
#[UniqueEntity(fields: ['email'], message: 'Cette adresse mail est déjà utilisée')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
const ROLE_USER = ['ROLE_USER'];
const ROLE_COMMERCIAL = ['ROLE_COMMERCIAL'];
const ROLE_GARAGISTE = ['ROLE_GARAGISTE'];
const ROLE_RESPONSABLE_GARAGE = ['ROLE_RESPONSABLE_GARAGE'];
const ROLE_ADMIN = ['ROLE_ADMIN'];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $nom = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $prenom = null;
#[ORM\Column(length: 100)]
private ?string $adresse = null;
#[ORM\Column(length: 15, nullable: true)]
private ?string $sexe = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column(length: 15, nullable: true)]
private ?string $tel = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $tokenRegistration = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $tokenRegistrationLifeTime = null;
#[ORM\Column]
private ?bool $isVerified = false;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: JobCard::class)]
private Collection $jobcards;
#[ORM\Column(length: 255, nullable: true)]
private ?string $typeClient = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $rccmFileName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $rccm = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Historique::class)]
private Collection $historiques;
#[ORM\OneToMany(mappedBy: 'responsable', targetEntity: Traveaux::class)]
private Collection $traveauxes;
#[ORM\Column(length: 50, nullable: true)]
private ?string $profil = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $NomCompletCommercial = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nomEtreprise = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $statusEntreprise = null;
public function getId(): ?int
{
return $this->id;
}
public function __construct()
{
$this->createdAt = new DateTimeImmutable();
$this->updatedAt = new DateTimeImmutable();
$this->isVerified = false;
$this->tokenRegistrationLifeTime = (new DateTime('now'))->add(new DateInterval("P1D"));
$this->jobcards = new ArrayCollection();
$this->historiques = new ArrayCollection();
$this->traveauxes = new ArrayCollection();
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): 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): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// 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): static
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(?string $prenom): static
{
$this->prenom = $prenom;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): static
{
$this->adresse = $adresse;
return $this;
}
public function getSexe(): ?string
{
return $this->sexe;
}
public function setSexe(?string $sexe): static
{
$this->sexe = $sexe;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(?string $tel): static
{
$this->tel = $tel;
return $this;
}
public function getTokenRegistration(): ?string
{
return $this->tokenRegistration;
}
public function setTokenRegistration(?string $tokenRegistration): static
{
$this->tokenRegistration = $tokenRegistration;
return $this;
}
public function getTokenRegistrationLifeTime(): ?\DateTimeInterface
{
return $this->tokenRegistrationLifeTime;
}
public function setTokenRegistrationLifeTime(\DateTimeInterface $tokenRegistrationLifeTime): static
{
$this->tokenRegistrationLifeTime = $tokenRegistrationLifeTime;
return $this;
}
public function isIsVerified(): ?bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): static
{
$this->isVerified = $isVerified;
return $this;
}
public function __toString()
{
return $this->nom;
}
/**
* @return Collection<int, JobCard>
*/
public function getJobcards(): Collection
{
return $this->jobcards;
}
public function addJobcard(JobCard $jobcard): static
{
if (!$this->jobcards->contains($jobcard)) {
$this->jobcards->add($jobcard);
$jobcard->setUser($this);
}
return $this;
}
public function removeJobcard(JobCard $jobcard): static
{
if ($this->jobcards->removeElement($jobcard)) {
// set the owning side to null (unless already changed)
if ($jobcard->getUser() === $this) {
$jobcard->setUser(null);
}
}
return $this;
}
public function getTypeClient(): ?string
{
return $this->typeClient;
}
public function setTypeClient(?string $typeClient): static
{
$this->typeClient = $typeClient;
return $this;
}
public function getRccmFileName(): ?string
{
return $this->rccmFileName;
}
public function setRccmFileName(?string $rccmFileName): static
{
$this->rccmFileName = $rccmFileName;
return $this;
}
public function getRccm(): ?string
{
return $this->rccm;
}
public function setRccm(?string $rccm): static
{
$this->rccm = $rccm;
return $this;
}
/**
* @return Collection<int, Historique>
*/
public function getHistoriques(): Collection
{
return $this->historiques;
}
public function addHistorique(Historique $historique): static
{
if (!$this->historiques->contains($historique)) {
$this->historiques->add($historique);
$historique->setUser($this);
}
return $this;
}
public function removeHistorique(Historique $historique): static
{
if ($this->historiques->removeElement($historique)) {
// set the owning side to null (unless already changed)
if ($historique->getUser() === $this) {
$historique->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Traveaux>
*/
public function getTraveauxes(): Collection
{
return $this->traveauxes;
}
public function addTraveaux(Traveaux $traveaux): static
{
if (!$this->traveauxes->contains($traveaux)) {
$this->traveauxes->add($traveaux);
$traveaux->setResponsable($this);
}
return $this;
}
public function removeTraveaux(Traveaux $traveaux): static
{
if ($this->traveauxes->removeElement($traveaux)) {
// set the owning side to null (unless already changed)
if ($traveaux->getResponsable() === $this) {
$traveaux->setResponsable(null);
}
}
return $this;
}
public function getProfil(): ?string
{
return $this->profil;
}
public function setProfil(?string $profil): static
{
$this->profil = $profil;
return $this;
}
public function getNomCompletCommercial(): ?string
{
return $this->NomCompletCommercial;
}
public function setNomCompletCommercial(?string $NomCompletCommercial): static
{
$this->NomCompletCommercial = $NomCompletCommercial;
return $this;
}
public function getNomEtreprise(): ?string
{
return $this->nomEtreprise;
}
public function setNomEtreprise(?string $nomEtreprise): static
{
$this->nomEtreprise = $nomEtreprise;
return $this;
}
public function getStatusEntreprise(): ?string
{
return $this->statusEntreprise;
}
public function setStatusEntreprise(?string $statusEntreprise): static
{
$this->statusEntreprise = $statusEntreprise;
return $this;
}
}