src/Entity/Participant.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Exception;
  8. use Symfony\Component\Uid\Uuid;
  9. /**
  10.  * Participant
  11.  *
  12.  * @ORM\Table(name="participant")
  13.  * @ORM\Entity(repositoryClass="App\Repository\ParticipantRepository")
  14.  * @ORM\HasLifecycleCallbacks
  15.  */
  16. class Participant
  17. {
  18.     public const STATUS_ENABLED_PRINTED 2;
  19.     public const STATUS_ENABLED_NOT_PRINTED 1;
  20.     public const STATUS_DISABLED 0;
  21.     /**
  22.      * @var int
  23.      *
  24.      * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="IDENTITY")
  27.      */
  28.     private int $id;
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  33.      */
  34.     private string $name;
  35.     /**
  36.      * @var string|null
  37.      *
  38.      * @ORM\Column(name="company", type="string", length=255, nullable=true)
  39.      */
  40.     private ?string $company;
  41.     /**
  42.      * @ORM\Column(name="vat_id", type="string", length=255, nullable=true)
  43.      */
  44.     private ?string $vatId;
  45.     /**
  46.      * @var string|null
  47.      *
  48.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  49.      */
  50.     private ?string $email;
  51.     /**
  52.      * @var string|null
  53.      *
  54.      * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  55.      */
  56.     private ?string $phone;
  57.     /**
  58.      * @ORM\Column(type="integer", nullable=true, options={"default"="0"})
  59.      */
  60.     private int $score 0;
  61.     /**
  62.      * @var DateTime|null
  63.      *
  64.      * @ORM\Column(name="print_date", type="datetime", nullable=true)
  65.      */
  66.     private ?DateTime $printDate null;
  67.     /**
  68.      * @var int|null
  69.      *
  70.      * @ORM\Column(name="status", type="integer", nullable=false, options={"default": 1})
  71.      */
  72.     private ?int $status self::STATUS_ENABLED_NOT_PRINTED;
  73.     /**
  74.      * @var \DateTime
  75.      *
  76.      * @ORM\Column(name="date_added", type="datetime", nullable=false)
  77.      */
  78.     private DateTime $dateAdded;
  79.     /**
  80.      * @var \DateTime
  81.      *
  82.      * @ORM\Column(name="modified_at", type="datetime", nullable=false)
  83.      */
  84.     private DateTime $modifiedAt;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=Package::class, inversedBy="participants")
  87.      * @ORM\JoinColumn(nullable=false)
  88.      */
  89.     private ?Package $package;
  90.     /**
  91.      * @ORM\Column(type="guid")
  92.      */
  93.     private ?string $secretCode;
  94.     /**
  95.      * @ORM\Column(type="datetime", nullable=true)
  96.      */
  97.     private ?\DateTimeInterface $qrSent;
  98.     /**
  99.      * @ORM\Column(type="datetime", nullable=true)
  100.      */
  101.     private ?\DateTimeInterface $qrResent;
  102.     /**
  103.      * @ORM\OneToMany(targetEntity=ParticipantAnswer::class, mappedBy="participant", orphanRemoval=true)
  104.      */
  105.     private $participantAnswers;
  106.     /**
  107.      * @ORM\OneToMany(targetEntity=ParticipantFile::class, mappedBy="participant")
  108.      */
  109.     private $participantFiles;
  110.     /**
  111.      * @ORM\Column(type="json", nullable=true)
  112.      */
  113.     private $customInputs = [];
  114.     public function __construct()
  115.     {
  116.         $this->dateAdded = new \DateTime();
  117.         $this->modifiedAt = new \DateTime();
  118.         $this->participantAnswers = new ArrayCollection();
  119.         $this->participantFiles = new ArrayCollection();
  120.     }
  121.     /**
  122.      * @return int
  123.      */
  124.     public function getId(): ?int
  125.     {
  126.         return $this->id;
  127.     }
  128.     /**
  129.      * @param int $id
  130.      * @return Participant
  131.      */
  132.     public function setId(int $id): Participant
  133.     {
  134.         $this->id $id;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return string
  139.      */
  140.     public function getName(): ?string
  141.     {
  142.         return $this->name;
  143.     }
  144.     /**
  145.      * @param string $name
  146.      * @return Participant
  147.      */
  148.     public function setName(string $name): Participant
  149.     {
  150.         $this->name $name;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return string|null
  155.      */
  156.     public function getCompany(): ?string
  157.     {
  158.         return $this->company;
  159.     }
  160.     /**
  161.      * @param string|null $company
  162.      * @return Participant
  163.      */
  164.     public function setCompany(?string $company): Participant
  165.     {
  166.         $this->company $company;
  167.         return $this;
  168.     }
  169.     public function getVatId(): ?string
  170.     {
  171.         return $this->vatId;
  172.     }
  173.     public function setVatId(string $vatId): self
  174.     {
  175.         $this->vatId $vatId;
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return string|null
  180.      */
  181.     public function getEmail(): ?string
  182.     {
  183.         return $this->email;
  184.     }
  185.     /**
  186.      * @param string|null $email
  187.      * @return Participant
  188.      */
  189.     public function setEmail(?string $email): Participant
  190.     {
  191.         $this->email $email;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return string|null
  196.      */
  197.     public function getPhone(): ?string
  198.     {
  199.         return $this->phone;
  200.     }
  201.     /**
  202.      * @param string|null $phone
  203.      * @return Participant
  204.      */
  205.     public function setPhone(?string $phone): Participant
  206.     {
  207.         $this->phone $phone;
  208.         return $this;
  209.     }
  210.     public function getScore(): ?int
  211.     {
  212.         return $this->score;
  213.     }
  214.     public function setScore(?int $score): self
  215.     {
  216.         $this->score $score;
  217.         return $this;
  218.     }
  219.     /**
  220.      * @return int
  221.      */
  222.     public function getStatus(): int
  223.     {
  224.         return $this->status;
  225.     }
  226.     /**
  227.      * @param int|null $status
  228.      * @return Participant
  229.      * @throws Exception
  230.      */
  231.     public function setStatus(?int $status): Participant
  232.     {
  233.         $this->status $status;
  234.         if ($status === self::STATUS_ENABLED_PRINTED && $this->getPrintDate() === null) {
  235.             $this->setPrintDate(new DateTime());
  236.         }
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return DateTime|null
  241.      */
  242.     public function getPrintDate(): ?DateTime
  243.     {
  244.         return $this->printDate;
  245.     }
  246.     /**
  247.      * @param DateTime|null $printDate
  248.      * @return Participant
  249.      */
  250.     public function setPrintDate(?DateTime $printDate): Participant
  251.     {
  252.         $this->printDate $printDate;
  253.         return $this;
  254.     }
  255.     /**
  256.      * @return DateTime
  257.      */
  258.     public function getDateAdded(): DateTime
  259.     {
  260.         return $this->dateAdded;
  261.     }
  262.     /**
  263.      * @param DateTime $dateAdded
  264.      */
  265.     public function setDateAdded(DateTime $dateAdded): void
  266.     {
  267.         $this->dateAdded $dateAdded;
  268.     }
  269.     /**
  270.      * @return DateTime
  271.      */
  272.     public function getModifiedAt(): DateTime
  273.     {
  274.         return $this->modifiedAt;
  275.     }
  276.     /**
  277.      * @param DateTime $modifiedAt
  278.      * @return Participant
  279.      */
  280.     public function setModifiedAt(DateTime $modifiedAt): Participant
  281.     {
  282.         $this->modifiedAt $modifiedAt;
  283.         return $this;
  284.     }
  285.     /**
  286.      * @ORM\PreFlush()
  287.      */
  288.     public function setDates(): void
  289.     {
  290.         $this->modifiedAt = new \DateTime();
  291.         $this->dateAdded = new \DateTime();
  292.     }
  293.     /**
  294.      * @ORM\PrePersist()
  295.      */
  296.     public function setGUID(): void
  297.     {
  298.         $this->secretCode Uuid::v4()->toRfc4122();
  299.     }
  300.     public function getPackage(): ?Package
  301.     {
  302.         return $this->package;
  303.     }
  304.     public function setPackage(?Package $package): self
  305.     {
  306.         $this->package $package;
  307.         return $this;
  308.     }
  309.     public function getSecretCode(): ?string
  310.     {
  311.         return $this->secretCode;
  312.     }
  313.     public function setSecretCode(string $secretCode): self
  314.     {
  315.         $this->secretCode $secretCode;
  316.         return $this;
  317.     }
  318.     public function getQrSent(): ?\DateTimeInterface
  319.     {
  320.         return $this->qrSent;
  321.     }
  322.     public function setQrSent(?\DateTimeInterface $qrSent): self
  323.     {
  324.         $this->qrSent $qrSent;
  325.         return $this;
  326.     }
  327.     /**
  328.      * @return \DateTimeInterface|null
  329.      */
  330.     public function getQrResent(): ?\DateTimeInterface
  331.     {
  332.         return $this->qrResent;
  333.     }
  334.     /**
  335.      * @param \DateTimeInterface|null $qrResent
  336.      * @return Participant
  337.      */
  338.     public function setQrResent(?\DateTimeInterface $qrResent): Participant
  339.     {
  340.         $this->qrResent $qrResent;
  341.         return $this;
  342.     }
  343.     /**
  344.      * @return Collection<int, ParticipantAnswer>
  345.      */
  346.     public function getParticipantAnswers(): Collection
  347.     {
  348.         return $this->participantAnswers;
  349.     }
  350.     public function addParticipantAnswer(ParticipantAnswer $participantAnswer): self
  351.     {
  352.         if (!$this->participantAnswers->contains($participantAnswer)) {
  353.             $this->participantAnswers[] = $participantAnswer;
  354.             $participantAnswer->setParticipant($this);
  355.         }
  356.         return $this;
  357.     }
  358.     public function removeParticipantAnswer(ParticipantAnswer $participantAnswer): self
  359.     {
  360.         if ($this->participantAnswers->removeElement($participantAnswer)) {
  361.             // set the owning side to null (unless already changed)
  362.             if ($participantAnswer->getParticipant() === $this) {
  363.                 $participantAnswer->setParticipant(null);
  364.             }
  365.         }
  366.         return $this;
  367.     }
  368.     /**
  369.      * @return Collection<int, ParticipantFile>
  370.      */
  371.     public function getParticipantFiles(): Collection
  372.     {
  373.         return $this->participantFiles;
  374.     }
  375.     public function addParticipantFile(ParticipantFile $participantFile): self
  376.     {
  377.         if (!$this->participantFiles->contains($participantFile)) {
  378.             $this->participantFiles[] = $participantFile;
  379.             $participantFile->setParticipant($this);
  380.         }
  381.         return $this;
  382.     }
  383.     public function removeParticipantFile(ParticipantFile $participantFile): self
  384.     {
  385.         if ($this->participantFiles->removeElement($participantFile)) {
  386.             // set the owning side to null (unless already changed)
  387.             if ($participantFile->getParticipant() === $this) {
  388.                 $participantFile->setParticipant(null);
  389.             }
  390.         }
  391.         return $this;
  392.     }
  393.     public function getCustomInputs(): ?array
  394.     {
  395.         return $this->customInputs;
  396.     }
  397.     public function setCustomInputs(?array $customInputs): self
  398.     {
  399.         $this->customInputs $customInputs;
  400.         return $this;
  401.     }
  402. }