entité
This commit is contained in:
209
src/Entity/Participant.php
Normal file
209
src/Entity/Participant.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ParticipantRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ParticipantRepository::class)]
|
||||
class Participant
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: 'uuid', unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $idParticipant = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $nom = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $prénom = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $telephone = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $mail = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $administrateur = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $actif = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private array $roles = [];
|
||||
|
||||
#[ORM\Column]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'participants')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Site $site = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Sortie>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'participant')]
|
||||
private Collection $sorties;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->idParticipant = Uuid::v4(); // Génération automatique de l'UUID
|
||||
$this->sorties = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getIdParticipant(): ?Uuid
|
||||
{
|
||||
return $this->idParticipant;
|
||||
}
|
||||
|
||||
public function getNom(): ?string
|
||||
{
|
||||
return $this->nom;
|
||||
}
|
||||
|
||||
public function setNom(string $nom): self
|
||||
{
|
||||
$this->nom = $nom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrénom(): ?string
|
||||
{
|
||||
return $this->prénom;
|
||||
}
|
||||
|
||||
public function setPrénom(string $prénom): self
|
||||
{
|
||||
$this->prénom = $prénom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTelephone(): ?string
|
||||
{
|
||||
return $this->telephone;
|
||||
}
|
||||
|
||||
public function setTelephone(?string $telephone): self
|
||||
{
|
||||
$this->telephone = $telephone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMail(): ?string
|
||||
{
|
||||
return $this->mail;
|
||||
}
|
||||
|
||||
public function setMail(?string $mail): self
|
||||
{
|
||||
$this->mail = $mail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAdministrateur(): ?bool
|
||||
{
|
||||
return $this->administrateur;
|
||||
}
|
||||
|
||||
public function setAdministrateur(bool $administrateur): self
|
||||
{
|
||||
$this->administrateur = $administrateur;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActif(): ?bool
|
||||
{
|
||||
return $this->actif;
|
||||
}
|
||||
|
||||
public function setActif(bool $actif): self
|
||||
{
|
||||
$this->actif = $actif;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
$roles = $this->roles;
|
||||
// Garantit que chaque utilisateur a au moins le rôle ROLE_USER
|
||||
$roles[] = 'ROLE_USER';
|
||||
|
||||
return array_unique($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $roles
|
||||
*/
|
||||
public function setRoles(array $roles): self
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword(): ?string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): self
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSite(): ?Site
|
||||
{
|
||||
return $this->site;
|
||||
}
|
||||
|
||||
public function setSite(?Site $site): self
|
||||
{
|
||||
$this->site = $site;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Sortie>
|
||||
*/
|
||||
public function getSorties(): Collection
|
||||
{
|
||||
return $this->sorties;
|
||||
}
|
||||
|
||||
public function addSortie(Sortie $sortie): self
|
||||
{
|
||||
if (!$this->sorties->contains($sortie)) {
|
||||
$this->sorties->add($sortie);
|
||||
$sortie->setParticipant($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSortie(Sortie $sortie): self
|
||||
{
|
||||
if ($this->sorties->removeElement($sortie)) {
|
||||
// Set the owning side to null (unless already changed)
|
||||
if ($sortie->getParticipant() === $this) {
|
||||
$sortie->setParticipant(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user