FestinHegre/src/Entity/Utilisateurs.php

181 lines
3.9 KiB
PHP
Raw Normal View History

<?php
namespace App\Entity;
use App\Repository\UtilisateursRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
#[ORM\Entity(repositoryClass: UtilisateursRepository::class)]
class Utilisateurs implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'SEQUENCE')]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $Nom = null;
#[ORM\Column(length: 255)]
private ?string $Prenom = null;
#[ORM\Column(length: 255, unique: true)]
private ?string $Mail = null;
#[ORM\Column(length: 255)]
private ?string $MotDePasse = null;
#[ORM\Column(type: 'json', length: 255)]
private array $Role = [];
/**
* @var Collection<int, Reservations>
*/
#[ORM\ManyToMany(targetEntity: Reservations::class, inversedBy: 'utilisateurs')]
private Collection $Reservation;
/**
* @var Collection<int, Tables>
*/
#[ORM\ManyToMany(targetEntity: Tables::class, inversedBy: 'utilisateurs')]
2024-10-27 23:29:20 +01:00
private Collection $table;
public function __construct()
{
$this->Reservation = new ArrayCollection();
2024-10-27 23:29:20 +01:00
$this->table = new ArrayCollection();
}
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;
}
public function getUserIdentifier(): string
{
return $this->Mail;
}
public function setUserIdentifier(string $userIdentifier): self
{
$this->Mail = $userIdentifier;
return $this;
}
public function getPassword(): ?string
{
return $this->MotDePasse;
}
public function setPassword(string $MotDePasse): static
{
$this->MotDePasse = $MotDePasse;
return $this;
}
public function getRoles(): array
{
return $this->Role;
}
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);
}
public function setRoles(array $Role): self
{
$this->Role = $Role;
return $this;
}
public function eraseCredentials(): void
{
// Méthode pour effacer les données sensibles (ex : plaintext password)
}
/**
* @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;
}
/**
* @return Collection<int, Tables>
*/
2024-10-27 23:29:20 +01:00
public function getTable(): Collection
{
2024-10-27 23:29:20 +01:00
return $this->table;
}
2024-10-27 23:29:20 +01:00
public function addTable(Tables $table): static
{
2024-10-27 23:29:20 +01:00
if (!$this->table->contains($table)) {
$this->table->add($table);
}
return $this;
}
2024-10-27 23:29:20 +01:00
public function removeTable(Tables $table): static
{
2024-10-27 23:29:20 +01:00
$this->table->removeElement($table);
return $this;
}
}