<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\Uid\Uuid;
/**
* Participant
*
* @ORM\Table(name="participant")
* @ORM\Entity(repositoryClass="App\Repository\ParticipantRepository")
* @ORM\HasLifecycleCallbacks
*/
class Participant
{
public const STATUS_ENABLED_PRINTED = 2;
public const STATUS_ENABLED_NOT_PRINTED = 1;
public const STATUS_DISABLED = 0;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private string $name;
/**
* @var string|null
*
* @ORM\Column(name="company", type="string", length=255, nullable=true)
*/
private ?string $company;
/**
* @ORM\Column(name="vat_id", type="string", length=255, nullable=true)
*/
private ?string $vatId;
/**
* @var string|null
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private ?string $email;
/**
* @var string|null
*
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
*/
private ?string $phone;
/**
* @ORM\Column(type="integer", nullable=true, options={"default"="0"})
*/
private int $score = 0;
/**
* @var DateTime|null
*
* @ORM\Column(name="print_date", type="datetime", nullable=true)
*/
private ?DateTime $printDate = null;
/**
* @var int|null
*
* @ORM\Column(name="status", type="integer", nullable=false, options={"default": 1})
*/
private ?int $status = self::STATUS_ENABLED_NOT_PRINTED;
/**
* @var \DateTime
*
* @ORM\Column(name="date_added", type="datetime", nullable=false)
*/
private DateTime $dateAdded;
/**
* @var \DateTime
*
* @ORM\Column(name="modified_at", type="datetime", nullable=false)
*/
private DateTime $modifiedAt;
/**
* @ORM\ManyToOne(targetEntity=Package::class, inversedBy="participants")
* @ORM\JoinColumn(nullable=false)
*/
private ?Package $package;
/**
* @ORM\Column(type="guid")
*/
private ?string $secretCode;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTimeInterface $qrSent;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTimeInterface $qrResent;
/**
* @ORM\OneToMany(targetEntity=ParticipantAnswer::class, mappedBy="participant", orphanRemoval=true)
*/
private $participantAnswers;
/**
* @ORM\OneToMany(targetEntity=ParticipantFile::class, mappedBy="participant")
*/
private $participantFiles;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $customInputs = [];
public function __construct()
{
$this->dateAdded = new \DateTime();
$this->modifiedAt = new \DateTime();
$this->participantAnswers = new ArrayCollection();
$this->participantFiles = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int $id
* @return Participant
*/
public function setId(int $id): Participant
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return Participant
*/
public function setName(string $name): Participant
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getCompany(): ?string
{
return $this->company;
}
/**
* @param string|null $company
* @return Participant
*/
public function setCompany(?string $company): Participant
{
$this->company = $company;
return $this;
}
public function getVatId(): ?string
{
return $this->vatId;
}
public function setVatId(string $vatId): self
{
$this->vatId = $vatId;
return $this;
}
/**
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param string|null $email
* @return Participant
*/
public function setEmail(?string $email): Participant
{
$this->email = $email;
return $this;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* @param string|null $phone
* @return Participant
*/
public function setPhone(?string $phone): Participant
{
$this->phone = $phone;
return $this;
}
public function getScore(): ?int
{
return $this->score;
}
public function setScore(?int $score): self
{
$this->score = $score;
return $this;
}
/**
* @return int
*/
public function getStatus(): int
{
return $this->status;
}
/**
* @param int|null $status
* @return Participant
* @throws Exception
*/
public function setStatus(?int $status): Participant
{
$this->status = $status;
if ($status === self::STATUS_ENABLED_PRINTED && $this->getPrintDate() === null) {
$this->setPrintDate(new DateTime());
}
return $this;
}
/**
* @return DateTime|null
*/
public function getPrintDate(): ?DateTime
{
return $this->printDate;
}
/**
* @param DateTime|null $printDate
* @return Participant
*/
public function setPrintDate(?DateTime $printDate): Participant
{
$this->printDate = $printDate;
return $this;
}
/**
* @return DateTime
*/
public function getDateAdded(): DateTime
{
return $this->dateAdded;
}
/**
* @param DateTime $dateAdded
*/
public function setDateAdded(DateTime $dateAdded): void
{
$this->dateAdded = $dateAdded;
}
/**
* @return DateTime
*/
public function getModifiedAt(): DateTime
{
return $this->modifiedAt;
}
/**
* @param DateTime $modifiedAt
* @return Participant
*/
public function setModifiedAt(DateTime $modifiedAt): Participant
{
$this->modifiedAt = $modifiedAt;
return $this;
}
/**
* @ORM\PreFlush()
*/
public function setDates(): void
{
$this->modifiedAt = new \DateTime();
$this->dateAdded = new \DateTime();
}
/**
* @ORM\PrePersist()
*/
public function setGUID(): void
{
$this->secretCode = Uuid::v4()->toRfc4122();
}
public function getPackage(): ?Package
{
return $this->package;
}
public function setPackage(?Package $package): self
{
$this->package = $package;
return $this;
}
public function getSecretCode(): ?string
{
return $this->secretCode;
}
public function setSecretCode(string $secretCode): self
{
$this->secretCode = $secretCode;
return $this;
}
public function getQrSent(): ?\DateTimeInterface
{
return $this->qrSent;
}
public function setQrSent(?\DateTimeInterface $qrSent): self
{
$this->qrSent = $qrSent;
return $this;
}
/**
* @return \DateTimeInterface|null
*/
public function getQrResent(): ?\DateTimeInterface
{
return $this->qrResent;
}
/**
* @param \DateTimeInterface|null $qrResent
* @return Participant
*/
public function setQrResent(?\DateTimeInterface $qrResent): Participant
{
$this->qrResent = $qrResent;
return $this;
}
/**
* @return Collection<int, ParticipantAnswer>
*/
public function getParticipantAnswers(): Collection
{
return $this->participantAnswers;
}
public function addParticipantAnswer(ParticipantAnswer $participantAnswer): self
{
if (!$this->participantAnswers->contains($participantAnswer)) {
$this->participantAnswers[] = $participantAnswer;
$participantAnswer->setParticipant($this);
}
return $this;
}
public function removeParticipantAnswer(ParticipantAnswer $participantAnswer): self
{
if ($this->participantAnswers->removeElement($participantAnswer)) {
// set the owning side to null (unless already changed)
if ($participantAnswer->getParticipant() === $this) {
$participantAnswer->setParticipant(null);
}
}
return $this;
}
/**
* @return Collection<int, ParticipantFile>
*/
public function getParticipantFiles(): Collection
{
return $this->participantFiles;
}
public function addParticipantFile(ParticipantFile $participantFile): self
{
if (!$this->participantFiles->contains($participantFile)) {
$this->participantFiles[] = $participantFile;
$participantFile->setParticipant($this);
}
return $this;
}
public function removeParticipantFile(ParticipantFile $participantFile): self
{
if ($this->participantFiles->removeElement($participantFile)) {
// set the owning side to null (unless already changed)
if ($participantFile->getParticipant() === $this) {
$participantFile->setParticipant(null);
}
}
return $this;
}
public function getCustomInputs(): ?array
{
return $this->customInputs;
}
public function setCustomInputs(?array $customInputs): self
{
$this->customInputs = $customInputs;
return $this;
}
}