<?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)]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[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: 255, nullable: true)]
private ?string $nom = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $prenom = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $tel = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $adresse = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $photo = null;
#[ORM\ManyToMany(targetEntity: Intervention::class, mappedBy: 'technicien')]
private Collection $interventionstec;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Intervention::class)]
private Collection $interventions;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Devis::class)]
private Collection $devis;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Historiquedemandedevis::class)]
private Collection $historiquedemandedevis;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Historiqueintervention::class)]
private Collection $historiqueinterventions;
public function __construct()
{
$this->interventionstec = new ArrayCollection();
$this->interventions = new ArrayCollection();
$this->devis = new ArrayCollection();
}
public function __toString(): string
{
// Retournez ici la représentation sous forme de chaîne de votre entité
// Par exemple, vous pouvez retourner une propriété spécifique de votre entité
// Exemple : retourner le nom de l'entité
return $this->nom;
}
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;
}
/**
* @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;
}
/**
* @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 getTel(): ?string
{
return $this->tel;
}
public function setTel(?string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(?string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
/**
* @return Collection<int, Intervention>
*/
public function getInterventionstec(): Collection
{
return $this->interventionstec;
}
public function addInterventionstec(Intervention $interventionstec): self
{
if (!$this->interventionstec->contains($interventionstec)) {
$this->interventionstec->add($interventionstec);
$interventionstec->addTechnicien($this);
}
return $this;
}
public function removeInterventionstec(Intervention $interventionstec): self
{
if ($this->interventionstec->removeElement($interventionstec)) {
$interventionstec->removeTechnicien($this);
}
return $this;
}
/**
* @return Collection<int, Intervention>
*/
public function getInterventions(): Collection
{
return $this->interventions;
}
public function addIntervention(Intervention $intervention): static
{
if (!$this->interventions->contains($intervention)) {
$this->interventions->add($intervention);
$intervention->setUser($this);
}
return $this;
}
public function removeIntervention(Intervention $intervention): static
{
if ($this->interventions->removeElement($intervention)) {
// set the owning side to null (unless already changed)
if ($intervention->getUser() === $this) {
$intervention->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Devis>
*/
public function getDevis(): Collection
{
return $this->devis;
}
public function addDevi(Devis $devi): static
{
if (!$this->devis->contains($devi)) {
$this->devis->add($devi);
$devi->setUser($this);
}
return $this;
}
public function removeDevi(Devis $devi): static
{
if ($this->devis->removeElement($devi)) {
// set the owning side to null (unless already changed)
if ($devi->getUser() === $this) {
$devi->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Historiquedemandedevis>
*/
public function getHistoriquedemandedevis(): Collection
{
return $this->historiquedemandedevis;
}
public function addHistoriquedemandedevi(Historiquedemandedevis $historiquedemandedevi): static
{
if (!$this->historiquedemandedevis->contains($historiquedemandedevi)) {
$this->historiquedemandedevis->add($historiquedemandedevi);
$historiquedemandedevi->setUser($this);
}
return $this;
}
public function removeHistoriquedemandedevi(Historiquedemandedevis $historiquedemandedevi): static
{
if ($this->historiquedemandedevis->removeElement($historiquedemandedevi)) {
// set the owning side to null (unless already changed)
if ($historiquedemandedevi->getUser() === $this) {
$historiquedemandedevi->setUser(null);
}
}
return $this;
}
public function getHistoriqueinterventions(): Collection
{
return $this->historiqueinterventions;
}
public function setHistoriqueinterventions(Collection $historiqueinterventions): void
{
$this->historiqueinterventions = $historiqueinterventions;
}
}