<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\HoureRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: HoureRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['houre:read']],
)]
class Houre
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(["houre:read",'reservation:read','abonnement:read'])]
private $id;
#[ORM\Column(type: 'time')]
#[Groups(["houre:read",'reservation:read','abonnement:read'])]
private $houreStart;
#[ORM\Column(type: 'time')]
#[Groups(["houre:read",'reservation:read','abonnement:read'])]
private $houreEnd;
#[ORM\OneToMany(mappedBy: 'houre', targetEntity: PitchDisponibility::class)]
private $pitchDisponibilities;
public function __construct()
{
$this->reservations = new ArrayCollection();
$this->pitchDisponibilities = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getHoureStart(): ?\DateTimeInterface
{
return $this->houreStart;
}
public function setHoureStart(\DateTimeInterface $houreStart): self
{
$this->houreStart = $houreStart;
return $this;
}
public function getHoureEnd(): ?\DateTimeInterface
{
return $this->houreEnd;
}
public function setHoureEnd(\DateTimeInterface $houreEnd): self
{
$this->houreEnd = $houreEnd;
return $this;
}
/**
* @return Collection<int, PitchDisponibility>
*/
public function getPitchDisponibilities(): Collection
{
return $this->pitchDisponibilities;
}
public function addPitchDisponibility(PitchDisponibility $pitchDisponibility): self
{
if (!$this->pitchDisponibilities->contains($pitchDisponibility)) {
$this->pitchDisponibilities[] = $pitchDisponibility;
$pitchDisponibility->setHoure($this);
}
return $this;
}
public function removePitchDisponibility(PitchDisponibility $pitchDisponibility): self
{
if ($this->pitchDisponibilities->removeElement($pitchDisponibility)) {
// set the owning side to null (unless already changed)
if ($pitchDisponibility->getHoure() === $this) {
$pitchDisponibility->setHoure(null);
}
}
return $this;
}
}