<?php
namespace App\Entity;
use App\Repository\SpectateurRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SpectateurRepository::class)]
class Spectateur
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
private ?Events $event = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\Column(nullable: true)]
private ?bool $isActive = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date = null;
#[ORM\ManyToOne(inversedBy: 'spectateurs')]
private ?Commande $commande = null;
#[ORM\OneToOne(mappedBy: "spectateur", targetEntity: Attribution::class, orphanRemoval: true)]
private $attribution;
public function __construct()
{
$this->date = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getEvent(): ?Events
{
return $this->event;
}
public function setEvent(?Events $event): self
{
$this->event = $event;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return ($this->date) ? $this->date : new \DateTime();
}
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getCommande(): ?Commande
{
return $this->commande;
}
public function setCommande(?Commande $commande): self
{
$this->commande = $commande;
return $this;
}
public function getLocalizedDate(): string
{
setlocale(LC_ALL, 'fr_FR.utf8');
return strftime('%A %d %B %Y', $this->getDate()->getTimestamp());
}
public function __toString(): string
{
// TODO: Implement __toString() method.
return $this->getNom();
}
public function getAttribution(): ?Attribution
{
return $this->attribution;
}
public function setAttribution(Attribution $attribution): self
{
$this->attribution = $attribution;
// set the owning side of the relation if necessary
if ($attribution->getSpectateur() !== $this) {
$attribution->setSpectateur($this);
}
return $this;
}
public function __clone(): void
{
if ($this->id) {
$this->id = null;
$this->event = null;
$this->attribution = null;
}
}
}