<?php
namespace App\Entity;
use App\Repository\CompetitionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CompetitionRepository::class)]
class Competition
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[ORM\ManyToOne(targetEntity: City::class, inversedBy: 'competitions')]
private $city;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $hall;
#[ORM\Column(type: 'date')]
private $date;
#[ORM\Column(type: 'date', nullable: true)]
private $checkin;
#[ORM\Column(type: 'date', nullable: true)]
private $checkout;
#[ORM\Column(type: 'datetime', nullable: true)]
private $deadline;
#[ORM\Column(type: 'integer', nullable: true)]
private $timezone;
#[ORM\OneToMany(mappedBy: 'competition', targetEntity: Attribution::class)]
private $attributions;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $brochureFile;
#[ORM\Column(type: 'date', nullable: true)]
private $dateend;
public function __construct()
{
$this->attributions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getHall(): ?string
{
return $this->hall;
}
public function setHall(?string $hall): self
{
$this->hall = $hall;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getCheckin(): ?\DateTimeInterface
{
return $this->checkin;
}
public function setCheckin(?\DateTimeInterface $checkin): self
{
$this->checkin = $checkin;
return $this;
}
public function getCheckout(): ?\DateTimeInterface
{
return $this->checkout;
}
public function setCheckout(?\DateTimeInterface $checkout): self
{
$this->checkout = $checkout;
return $this;
}
public function getDeadline(): ?\DateTimeInterface
{
return $this->deadline;
}
public function setDeadline(?\DateTimeInterface $deadline): self
{
$this->deadline = $deadline;
return $this;
}
public function getTimezone(): ?int
{
return $this->timezone;
}
public function setTimezone(?int $timezone): self
{
$this->timezone = $timezone;
return $this;
}
/**
* @return Collection|Attribution[]
*/
public function getAttributions(): Collection
{
return $this->attributions;
}
public function addAttribution(Attribution $attribution): self
{
if (!$this->attributions->contains($attribution)) {
$this->attributions[] = $attribution;
$attribution->setCompetition($this);
}
return $this;
}
public function removeAttribution(Attribution $attribution): self
{
if ($this->attributions->removeElement($attribution)) {
// set the owning side to null (unless already changed)
if ($attribution->getCompetition() === $this) {
$attribution->setCompetition(null);
}
}
return $this;
}
public function getTimeLeft()
{
$deadline = $this->getDeadline();
return [
'Y' => $deadline->format('Y'),
'm' => $deadline->format('m'),
'd' => $deadline->format('d'),
'h' => $deadline->format('h'),
'i' => $deadline->format('i'),
's' => $deadline->format('s')
];
}
public function __toString()
{
return $this->title;
}
public function getBrochureFile(): ?string
{
return $this->brochureFile;
}
public function setBrochureFile(?string $brochureFile): self
{
$this->brochureFile = $brochureFile;
return $this;
}
public function getDateend(): ?\DateTimeInterface
{
return $this->dateend;
}
public function setDateend(?\DateTimeInterface $dateend): self
{
$this->dateend = $dateend;
return $this;
}
}