<?php
namespace App\Entity;
use App\Repository\QuizResultatRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: QuizResultatRepository::class)]
class QuizResultat
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\OneToMany(mappedBy: 'quizResultat', targetEntity: QuizMention::class, cascade: ['persist', 'remove'])]
#[Assert\Valid]
private Collection $mention;
#[ORM\ManyToOne(inversedBy: 'quizResultats')]
#[ORM\JoinColumn(nullable: false)]
#[Assert\NotNull]
private ?Quiz $quiz = null;
#[ORM\Column]
private ?bool $selected = null;
public function __construct()
{
$this->mention = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, QuizMention>
*/
public function getMention(): Collection
{
return $this->mention;
}
public function addMention(QuizMention $mention): self
{
if (!$this->mention->contains($mention)) {
$this->mention->add($mention);
}
return $this;
}
public function removeMention(QuizMention $mention): self
{
if ($this->mention->removeElement($mention)) {
// set the owning side to null (unless already changed)
if ($mention->getQuizResultat() === $this) {
$mention->setQuizResultat(null);
}
}
return $this;
}
public function getQuiz(): ?Quiz
{
return $this->quiz;
}
public function setQuiz(?Quiz $quiz): self
{
$this->quiz = $quiz;
return $this;
}
public function isSelected(): ?bool
{
return $this->selected;
}
public function setSelected(bool $selected): self
{
$this->selected = $selected;
return $this;
}
}