(Clients/Tables Reservations/Utilisateurs) Test ManyToOne Gauche schema (Reservations -> Tables)
107 lines
2.3 KiB
PHP
107 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\ReservationsRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: ReservationsRepository::class)]
|
|
class Reservations
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
|
private ?\DateTimeInterface $DateHeure = null;
|
|
|
|
#[ORM\Column]
|
|
private ?int $Nb_de_prsn = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'reservations')]
|
|
private ?Tables $Tabl = null;
|
|
|
|
/**
|
|
* @var Collection<int, Utilisateurs>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Utilisateurs::class, mappedBy: 'Reservation')]
|
|
private Collection $utilisateurs;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->utilisateurs = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getDateHeure(): ?\DateTimeInterface
|
|
{
|
|
return $this->DateHeure;
|
|
}
|
|
|
|
public function setDateHeure(\DateTimeInterface $DateHeure): static
|
|
{
|
|
$this->DateHeure = $DateHeure;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getNbDePrsn(): ?int
|
|
{
|
|
return $this->Nb_de_prsn;
|
|
}
|
|
|
|
public function setNbDePrsn(int $Nb_de_prsn): static
|
|
{
|
|
$this->Nb_de_prsn = $Nb_de_prsn;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTabl(): ?Tables
|
|
{
|
|
return $this->Tabl;
|
|
}
|
|
|
|
public function setTabl(?Tables $Tabl): static
|
|
{
|
|
$this->Tabl = $Tabl;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Utilisateurs>
|
|
*/
|
|
public function getUtilisateurs(): Collection
|
|
{
|
|
return $this->utilisateurs;
|
|
}
|
|
|
|
public function addUtilisateur(Utilisateurs $utilisateur): static
|
|
{
|
|
if (!$this->utilisateurs->contains($utilisateur)) {
|
|
$this->utilisateurs->add($utilisateur);
|
|
$utilisateur->addReservation($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeUtilisateur(Utilisateurs $utilisateur): static
|
|
{
|
|
if ($this->utilisateurs->removeElement($utilisateur)) {
|
|
$utilisateur->removeReservation($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|