src/Entity/Quiz.php line 14
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\QuizRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: QuizRepository::class)]#[ApiResource]class Quiz{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(type: Types::TEXT)]private ?string $description = null;#[ORM\Column(type: Types::TEXT)]private ?string $requirement = null;#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: Question::class, cascade: ['persist'],orphanRemoval: true)]private Collection $questions;#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: Lesson::class)]private Collection $lessons;#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: GivenAnswere::class),]private Collection $givenAnsweres;public function __construct(){$this->questions = new ArrayCollection();$this->lessons = new ArrayCollection();$this->givenAnsweres = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function __toString(): string{return $this->name;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(string $description): self{$this->description = $description;return $this;}public function getRequirement(): ?string{return $this->requirement;}public function setRequirement(string $requirement): self{$this->requirement = $requirement;return $this;}/*** @return Collection<int, Question>*/public function getQuestions(): Collection{return $this->questions;}public function addQuestion(Question $question): self{if (!$this->questions->contains($question)) {$this->questions->add($question);$question->setQuiz($this);}return $this;}public function removeQuestion(Question $question): self{if ($this->questions->removeElement($question)) {// set the owning side to null (unless already changed)if ($question->getQuiz() === $this) {$question->setQuiz(null);}}return $this;}/*** @return Collection<int, Lesson>*/public function getLessons(): Collection{return $this->lessons;}public function addLesson(Lesson $lesson): self{if (!$this->lessons->contains($lesson)) {$this->lessons->add($lesson);$lesson->setQuiz($this);}return $this;}public function removeLesson(Lesson $lesson): self{if ($this->lessons->removeElement($lesson)) {// set the owning side to null (unless already changed)if ($lesson->getQuiz() === $this) {$lesson->setQuiz(null);}}return $this;}/*** @return Collection<int, GivenAnswere>*/public function getGivenAnsweres(): Collection{return $this->givenAnsweres;}public function addGivenAnswere(GivenAnswere $givenAnswere): self{if (!$this->givenAnsweres->contains($givenAnswere)) {$this->givenAnsweres->add($givenAnswere);$givenAnswere->setQuiz($this);}return $this;}public function removeGivenAnswere(GivenAnswere $givenAnswere): self{if ($this->givenAnsweres->removeElement($givenAnswere)) {// set the owning side to null (unless already changed)if ($givenAnswere->getQuiz() === $this) {$givenAnswere->setQuiz(null);}}return $this;}}