mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20:44:19 +01:00
WIP 3-3
This commit is contained in:
105
src/Entity/Quiz.php
Normal file
105
src/Entity/Quiz.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\QuizRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: QuizRepository::class)]
|
||||
class Quiz
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private string $name;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'quizzes')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Season $season;
|
||||
|
||||
/** @var Collection<int, Question> */
|
||||
#[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
|
||||
private Collection $questions;
|
||||
|
||||
/** @var Collection<int, Correction> */
|
||||
#[ORM\OneToMany(targetEntity: Correction::class, mappedBy: 'quiz', orphanRemoval: true)]
|
||||
private Collection $corrections;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->questions = new ArrayCollection();
|
||||
$this->corrections = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeason(): Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Question> */
|
||||
public function getQuestions(): Collection
|
||||
{
|
||||
return $this->questions;
|
||||
}
|
||||
|
||||
public function addQuestion(Question $question): static
|
||||
{
|
||||
if (!$this->questions->contains($question)) {
|
||||
$this->questions->add($question);
|
||||
$question->setQuiz($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Collection<int, Correction> */
|
||||
public function getCorrections(): Collection
|
||||
{
|
||||
return $this->corrections;
|
||||
}
|
||||
|
||||
public function addCorrection(Correction $correction): static
|
||||
{
|
||||
if (!$this->corrections->contains($correction)) {
|
||||
$this->corrections->add($correction);
|
||||
$correction->setQuiz($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user