2024-10-16 20:43:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use App\Repository\UtilisateursRepository;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2024-10-25 19:15:26 +02:00
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
2024-10-16 20:43:05 +02:00
|
|
|
|
|
|
|
#[ORM\Entity(repositoryClass: UtilisateursRepository::class)]
|
2024-10-25 19:15:26 +02:00
|
|
|
class Utilisateurs implements UserInterface, PasswordAuthenticatedUserInterface
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
#[ORM\Id]
|
2024-10-25 19:15:26 +02:00
|
|
|
#[ORM\GeneratedValue(strategy: 'SEQUENCE')]
|
2024-10-16 20:43:05 +02:00
|
|
|
#[ORM\Column]
|
|
|
|
private ?int $id = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
private ?string $Nom = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
private ?string $Prenom = null;
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
#[ORM\Column(length: 255, unique: true)]
|
2024-10-16 20:43:05 +02:00
|
|
|
private ?string $Mail = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
private ?string $MotDePasse = null;
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
#[ORM\Column(type: 'json', length: 255)]
|
|
|
|
private array $Role = [];
|
2024-10-16 20:43:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Collection<int, Reservations>
|
|
|
|
*/
|
|
|
|
#[ORM\ManyToMany(targetEntity: Reservations::class, inversedBy: 'utilisateurs')]
|
|
|
|
private Collection $Reservation;
|
|
|
|
|
2024-10-17 16:34:44 +02:00
|
|
|
/**
|
|
|
|
* @var Collection<int, Tables>
|
|
|
|
*/
|
|
|
|
#[ORM\ManyToMany(targetEntity: Tables::class, inversedBy: 'utilisateurs')]
|
2024-10-27 23:29:20 +01:00
|
|
|
private Collection $table;
|
2024-10-17 16:34:44 +02:00
|
|
|
|
2024-10-16 20:43:05 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->Reservation = new ArrayCollection();
|
2024-10-27 23:29:20 +01:00
|
|
|
$this->table = new ArrayCollection();
|
2024-10-16 20:43:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function getUserIdentifier(): string
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
return $this->Mail;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function setUserIdentifier(string $userIdentifier): self
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
2024-10-25 19:15:26 +02:00
|
|
|
$this->Mail = $userIdentifier;
|
2024-10-16 20:43:05 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function getPassword(): ?string
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
return $this->MotDePasse;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function setPassword(string $MotDePasse): static
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
$this->MotDePasse = $MotDePasse;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function getRoles(): array
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
return $this->Role;
|
|
|
|
}
|
|
|
|
|
2024-10-28 02:45:24 +01:00
|
|
|
public function getRolesAsString(): string
|
|
|
|
{
|
|
|
|
// Supprime le préfixe "ROLE_" et formate en majuscule seulement la première lettre
|
|
|
|
$roles = array_map(function($role) {
|
|
|
|
return ucfirst(strtolower(str_replace('ROLE_', '', $role)));
|
|
|
|
}, $this->Role);
|
|
|
|
|
|
|
|
return implode(', ', $roles);
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function setRoles(array $Role): self
|
2024-10-16 20:43:05 +02:00
|
|
|
{
|
|
|
|
$this->Role = $Role;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:15:26 +02:00
|
|
|
public function eraseCredentials(): void
|
|
|
|
{
|
|
|
|
// Méthode pour effacer les données sensibles (ex : plaintext password)
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:43:05 +02:00
|
|
|
/**
|
|
|
|
* @return Collection<int, Reservations>
|
|
|
|
*/
|
|
|
|
public function getReservation(): Collection
|
|
|
|
{
|
|
|
|
return $this->Reservation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addReservation(Reservations $reservation): static
|
|
|
|
{
|
|
|
|
if (!$this->Reservation->contains($reservation)) {
|
|
|
|
$this->Reservation->add($reservation);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removeReservation(Reservations $reservation): static
|
|
|
|
{
|
|
|
|
$this->Reservation->removeElement($reservation);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2024-10-17 16:34:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection<int, Tables>
|
|
|
|
*/
|
2024-10-27 23:29:20 +01:00
|
|
|
public function getTable(): Collection
|
2024-10-17 16:34:44 +02:00
|
|
|
{
|
2024-10-27 23:29:20 +01:00
|
|
|
return $this->table;
|
2024-10-17 16:34:44 +02:00
|
|
|
}
|
|
|
|
|
2024-10-27 23:29:20 +01:00
|
|
|
public function addTable(Tables $table): static
|
2024-10-17 16:34:44 +02:00
|
|
|
{
|
2024-10-27 23:29:20 +01:00
|
|
|
if (!$this->table->contains($table)) {
|
|
|
|
$this->table->add($table);
|
2024-10-17 16:34:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2024-10-27 23:29:20 +01:00
|
|
|
public function removeTable(Tables $table): static
|
2024-10-17 16:34:44 +02:00
|
|
|
{
|
2024-10-27 23:29:20 +01:00
|
|
|
$this->table->removeElement($table);
|
2024-10-17 16:34:44 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2024-10-16 20:43:05 +02:00
|
|
|
}
|