<?php
namespace App\Entity;
use App\Repository\SessionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: SessionRepository::class)]
class Session
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
private ?Sport $design = null;
#[ORM\ManyToOne]
private ?Events $event = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $heure_start = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $heure_end = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne]
private ?SessionType $type = null;
#[ORM\ManyToOne]
private ?Cour $cour = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $codeSession = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $designationSession = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $typeSession = null;
#[ORM\Column(nullable: true)]
private ?float $first = null;
#[ORM\Column(nullable: true)]
private ?float $catA = null;
#[ORM\Column(nullable: true)]
private ?float $catB = null;
#[ORM\Column(nullable: true)]
private ?float $catC = null;
#[ORM\Column(nullable: true)]
private ?float $catD = null;
#[ORM\OneToMany(mappedBy: 'session', targetEntity: SerieBillet::class, cascade: ['persist'], orphanRemoval: true)]
private Collection $serieBillets;
public function __construct()
{
$this->serieBillets = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDesign(): ?Sport
{
return $this->design;
}
public function setDesign(?Sport $design): self
{
$this->design = $design;
return $this;
}
public function getEvent(): ?Events
{
return $this->event;
}
public function setEvent(?Events $event): self
{
$this->event = $event;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getHeureStart(): ?\DateTimeInterface
{
return $this->heure_start;
}
public function setHeureStart(?\DateTimeInterface $heure_start): self
{
$this->heure_start = $heure_start;
return $this;
}
public function getHeureEnd(): ?\DateTimeInterface
{
return $this->heure_end;
}
public function setHeureEnd(?\DateTimeInterface $heure_end): self
{
$this->heure_end = $heure_end;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getType(): ?SessionType
{
return $this->type;
}
public function setType(?SessionType $type): self
{
$this->type = $type;
return $this;
}
public function getCour(): ?Cour
{
return $this->cour;
}
public function setCour(?Cour $cour): self
{
$this->cour = $cour;
return $this;
}
public function getCodeSession(): ?string
{
return $this->codeSession;
}
public function setCodeSession(?string $codeSession): self
{
$this->codeSession = $codeSession;
return $this;
}
public function getDesignationSession(): ?string
{
return $this->designationSession;
}
public function setDesignationSession($designationSession): self
{
$this->designationSession = $designationSession;
return $this;
}
public function getTypeSession(): ?string
{
return $this->typeSession;
}
public function setTypeSession(?string $typeSession): self
{
$this->typeSession = $typeSession;
return $this;
}
public function getFirst(): ?float
{
return $this->first;
}
public function setFirst(?float $first): self
{
$this->first = $first;
return $this;
}
public function getCatA(): ?float
{
return $this->catA;
}
public function setCatA(?float $catA): self
{
$this->catA = $catA;
return $this;
}
public function getCatB(): ?float
{
return $this->catB;
}
public function setCatB(?float $catB): self
{
$this->catB = $catB;
return $this;
}
public function getCatC(): ?float
{
return $this->catC;
}
public function setCatC(?float $catC): self
{
$this->catC = $catC;
return $this;
}
public function getCatD(): ?float
{
return $this->catD;
}
public function setCatD(?float $catD): self
{
$this->catD = $catD;
return $this;
}
/**
* @return Collection<int, SerieBillet>
*/
public function getSerieBillets(): Collection
{
return $this->serieBillets;
}
public function addSerieBillet(SerieBillet $serieBillet): self
{
if (!$this->serieBillets->contains($serieBillet)) {
$this->serieBillets->add($serieBillet);
$serieBillet->setSession($this);
}
return $this;
}
public function removeSerieBillet(SerieBillet $serieBillet): self
{
if ($this->serieBillets->removeElement($serieBillet)) {
// set the owning side to null (unless already changed)
if ($serieBillet->getSession() === $this) {
$serieBillet->setSession(null);
}
}
return $this;
}
/**
* @return string
*/
public function getSportName(): string
{
return $this->design->getName();
}
public function getLocalizedDate(): string
{
$formatter = new \IntlDateFormatter('fr_FR', \IntlDateFormatter::FULL, \IntlDateFormatter::NONE, 'Europe/Paris', \IntlDateFormatter::GREGORIAN, 'EEEE dd MMMM yyyy');
return $formatter->format($this->getDate());
}
public function __toString()
{
return (string) $this->codeSession;
}
}