<?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 $tables = 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 getTables(): ?Tables
    {
        return $this->tables;
    }

    public function setTable(?Tables $tables): static
    {
        $this->tables = $tables;

        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;
    }
}
