<?php namespace App\Entity; use App\Repository\QuizAnswerRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=QuizAnswerRepository::class) */ class QuizAnswer { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private ?string $text; /** * @ORM\Column(type="boolean", options={"default":false}) */ private bool $isRight = FALSE; /** * @ORM\Column(type="integer", nullable=true) */ private ?int $orderIndex; /** * @ORM\ManyToOne(targetEntity=QuizQuestion::class, inversedBy="quizAnswers") */ private ?QuizQuestion $quizQuestion; /** * @ORM\OneToMany(targetEntity=QuizUserAnswer::class, mappedBy="quizAnswer", cascade={"persist", "remove"}) */ private $quizUserAnswers; public function __construct() { $this->quizUserAnswers = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getText(): ?string { return $this->text; } public function setText( string $text ): QuizAnswer { $this->text = $text; return $this; } public function getIsRight(): ?bool { return $this->isRight; } public function setIsRight( bool $isRight ): QuizAnswer { $this->isRight = $isRight; return $this; } public function getOrderIndex(): ?int { return $this->orderIndex; } public function setOrderIndex( ?int $orderIndex ): QuizAnswer { $this->orderIndex = $orderIndex; return $this; } public function getQuizQuestion(): ?QuizQuestion { return $this->quizQuestion; } public function setQuizQuestion( ?QuizQuestion $quizQuestion ): QuizAnswer { $this->quizQuestion = $quizQuestion;// $quizQuestion->addQuizAnswer( $this ); return $this; } public function getQuizUserAnswers(): Collection { return $this->quizUserAnswers; } public function addQuizUserAnswer( QuizUserAnswer $quizUserAnswer ): QuizAnswer { if ( !$this->quizUserAnswers->contains( $quizUserAnswer ) ) { $this->quizUserAnswers[] = $quizUserAnswer; $quizUserAnswer->setQuizAnswer( $this ); } return $this; } public function removeQuizUserAnswer( QuizUserAnswer $quizUserAnswer ): QuizAnswer { if ( $this->quizUserAnswers->removeElement( $quizUserAnswer ) ) { // set the owning side to null (unless already changed) if ( $quizUserAnswer->getQuizAnswer() === $this ) { $quizUserAnswer->setQuizAnswer( NULL ); } } return $this; } }