src/Entity/User.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $nom null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $prenom null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $tel null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $adresse null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $photo null;
  37.     #[ORM\ManyToMany(targetEntityIntervention::class, mappedBy'technicien')]
  38.     private Collection $interventionstec;
  39.     #[ORM\OneToMany(mappedBy'user'targetEntityIntervention::class)]
  40.     private Collection $interventions;
  41.     #[ORM\OneToMany(mappedBy'user'targetEntityDevis::class)]
  42.     private Collection $devis;
  43.     #[ORM\OneToMany(mappedBy'user'targetEntityHistoriquedemandedevis::class)]
  44.     private Collection $historiquedemandedevis;
  45.     #[ORM\OneToMany(mappedBy'user'targetEntityHistoriqueintervention::class)]
  46.     private Collection $historiqueinterventions;
  47.     public function __construct()
  48.     {
  49.         $this->interventionstec = new ArrayCollection();
  50.         $this->interventions = new ArrayCollection();
  51.         $this->devis = new ArrayCollection();
  52.     }
  53.     public function __toString(): string
  54.     {
  55.         // Retournez ici la représentation sous forme de chaîne de votre entité
  56.         // Par exemple, vous pouvez retourner une propriété spécifique de votre entité
  57.         // Exemple : retourner le nom de l'entité
  58.         return $this->nom;
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getEmail(): ?string
  65.     {
  66.         return $this->email;
  67.     }
  68.     public function setEmail(string $email): self
  69.     {
  70.         $this->email $email;
  71.         return $this;
  72.     }
  73.     /**
  74.      * A visual identifier that represents this user.
  75.      *
  76.      * @see UserInterface
  77.      */
  78.     public function getUserIdentifier(): string
  79.     {
  80.         return (string) $this->email;
  81.     }
  82.     /**
  83.      * @see UserInterface
  84.      */
  85.     public function getRoles(): array
  86.     {
  87.         $roles $this->roles;
  88.         // guarantee every user at least has ROLE_USER
  89.         $roles[] = 'ROLE_USER';
  90.         return array_unique($roles);
  91.     }
  92.     public function setRoles(array $roles): self
  93.     {
  94.         $this->roles $roles;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @see PasswordAuthenticatedUserInterface
  99.      */
  100.     public function getPassword(): string
  101.     {
  102.         return $this->password;
  103.     }
  104.     public function setPassword(string $password): self
  105.     {
  106.         $this->password $password;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @see UserInterface
  111.      */
  112.     public function eraseCredentials()
  113.     {
  114.         // If you store any temporary, sensitive data on the user, clear it here
  115.         // $this->plainPassword = null;
  116.     }
  117.     public function getNom(): ?string
  118.     {
  119.         return $this->nom;
  120.     }
  121.     public function setNom(?string $nom): self
  122.     {
  123.         $this->nom $nom;
  124.         return $this;
  125.     }
  126.     public function getPrenom(): ?string
  127.     {
  128.         return $this->prenom;
  129.     }
  130.     public function setPrenom(?string $prenom): self
  131.     {
  132.         $this->prenom $prenom;
  133.         return $this;
  134.     }
  135.     public function getTel(): ?string
  136.     {
  137.         return $this->tel;
  138.     }
  139.     public function setTel(?string $tel): self
  140.     {
  141.         $this->tel $tel;
  142.         return $this;
  143.     }
  144.     public function getAdresse(): ?string
  145.     {
  146.         return $this->adresse;
  147.     }
  148.     public function setAdresse(?string $adresse): self
  149.     {
  150.         $this->adresse $adresse;
  151.         return $this;
  152.     }
  153.     public function getPhoto(): ?string
  154.     {
  155.         return $this->photo;
  156.     }
  157.     public function setPhoto(?string $photo): self
  158.     {
  159.         $this->photo $photo;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, Intervention>
  164.      */
  165.     public function getInterventionstec(): Collection
  166.     {
  167.         return $this->interventionstec;
  168.     }
  169.     public function addInterventionstec(Intervention $interventionstec): self
  170.     {
  171.         if (!$this->interventionstec->contains($interventionstec)) {
  172.             $this->interventionstec->add($interventionstec);
  173.             $interventionstec->addTechnicien($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removeInterventionstec(Intervention $interventionstec): self
  178.     {
  179.         if ($this->interventionstec->removeElement($interventionstec)) {
  180.             $interventionstec->removeTechnicien($this);
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, Intervention>
  186.      */
  187.     public function getInterventions(): Collection
  188.     {
  189.         return $this->interventions;
  190.     }
  191.     public function addIntervention(Intervention $intervention): static
  192.     {
  193.         if (!$this->interventions->contains($intervention)) {
  194.             $this->interventions->add($intervention);
  195.             $intervention->setUser($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeIntervention(Intervention $intervention): static
  200.     {
  201.         if ($this->interventions->removeElement($intervention)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($intervention->getUser() === $this) {
  204.                 $intervention->setUser(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Devis>
  211.      */
  212.     public function getDevis(): Collection
  213.     {
  214.         return $this->devis;
  215.     }
  216.     public function addDevi(Devis $devi): static
  217.     {
  218.         if (!$this->devis->contains($devi)) {
  219.             $this->devis->add($devi);
  220.             $devi->setUser($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeDevi(Devis $devi): static
  225.     {
  226.         if ($this->devis->removeElement($devi)) {
  227.             // set the owning side to null (unless already changed)
  228.             if ($devi->getUser() === $this) {
  229.                 $devi->setUser(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234.     /**
  235.      * @return Collection<int, Historiquedemandedevis>
  236.      */
  237.     public function getHistoriquedemandedevis(): Collection
  238.     {
  239.         return $this->historiquedemandedevis;
  240.     }
  241.     public function addHistoriquedemandedevi(Historiquedemandedevis $historiquedemandedevi): static
  242.     {
  243.         if (!$this->historiquedemandedevis->contains($historiquedemandedevi)) {
  244.             $this->historiquedemandedevis->add($historiquedemandedevi);
  245.             $historiquedemandedevi->setUser($this);
  246.         }
  247.         return $this;
  248.     }
  249.     public function removeHistoriquedemandedevi(Historiquedemandedevis $historiquedemandedevi): static
  250.     {
  251.         if ($this->historiquedemandedevis->removeElement($historiquedemandedevi)) {
  252.             // set the owning side to null (unless already changed)
  253.             if ($historiquedemandedevi->getUser() === $this) {
  254.                 $historiquedemandedevi->setUser(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     public function getHistoriqueinterventions(): Collection
  260.     {
  261.         return $this->historiqueinterventions;
  262.     }
  263.     public function setHistoriqueinterventions(Collection $historiqueinterventions): void
  264.     {
  265.         $this->historiqueinterventions $historiqueinterventions;
  266.     }
  267. }