<?php
namespace App\Entity;
use App\Repository\SessionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SessionRepository::class)
*/
class Session
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="date")
*/
private $date;
/**
* @ORM\Column(type="integer")
*/
private $numberD;
/**
* @ORM\ManyToOne(targetEntity=Movie::class, inversedBy="sessions")
* @ORM\JoinColumn(nullable=false)
*/
private $idMovie;
/**
* @ORM\OneToMany(targetEntity=Reservation::class, mappedBy="idSession", orphanRemoval=true)
*/
private $reservations;
/**
* @ORM\Column(type="time")
*/
private $hours;
public function __construct()
{
$this->reservations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getNumberD(): ?int
{
return $this->numberD;
}
public function setNumberD(int $numberD): self
{
$this->numberD = $numberD;
return $this;
}
public function getIdMovie(): ?Movie
{
return $this->idMovie;
}
public function setIdMovie(?Movie $idMovie): self
{
$this->idMovie = $idMovie;
return $this;
}
/**
* @return Collection|Reservation[]
*/
public function getReservations(): Collection
{
return $this->reservations;
}
public function addReservation(Reservation $reservation): self
{
if (!$this->reservations->contains($reservation)) {
$this->reservations[] = $reservation;
$reservation->setIdSession($this);
}
return $this;
}
public function removeReservation(Reservation $reservation): self
{
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getIdSession() === $this) {
$reservation->setIdSession(null);
}
}
return $this;
}
public function getHours(): ?\DateTimeInterface
{
return $this->hours;
}
public function setHours(\DateTimeInterface $hours): self
{
$this->hours = $hours;
return $this;
}
}