<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\BFSeanceRepository")
*/
class BFSeance
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFTournoi", inversedBy="seances")
* @ORM\JoinColumn(nullable=false)
*/
private $tournoi;
/**
* @ORM\Column(type="datetime")
*/
private $startdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $creationdate;
public function __construct()
{
$this->creationdate = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getTournoi(): ?BFTournoi
{
return $this->tournoi;
}
public function setTournoi(?BFTournoi $tournoi): self
{
$this->tournoi = $tournoi;
return $this;
}
public function getStartdate(): ?\DateTimeInterface
{
return $this->startdate;
}
public function setStartdate(\DateTimeInterface $startdate): self
{
$this->startdate = $startdate;
return $this;
}
/**
* @Assert\IsTrue(message="Les dates ne sont pas comprises par celles du tournoi")
*/
public function isDatesInTournoi()
{
$startdateedition = $this->getTournoi()->getStartdate();
$enddateedition = $this->getTournoi()->getEnddate();
$enddateedition->add(new \DateInterval('P1D'));
return $this->startdate>=$startdateedition && $this->startdate<=$enddateedition;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(?\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
}