src/Entity/Quizz.php line 13

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\QuizzRepository;
  4.     use Doctrine\Common\Collections\ArrayCollection;
  5.     use Doctrine\Common\Collections\Collection;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     /**
  8.      * @ORM\Entity(repositoryClass=QuizzRepository::class)
  9.      */
  10.     class Quizz
  11.     {
  12.         //Quizz is not viewable by users
  13.         const STATUS_CLOSED 0;
  14.         //Quizz is answerable ( = writable)
  15.         const STATUS_OPENED 1;
  16.         //Quizz is viewable ( = read only)
  17.         const STATUS_FINISHED 2;
  18.         const STATUS = [
  19.             'fermé'   => 0,
  20.             'ouvert'  => 1,
  21.             'terminé' => 2,
  22.         ];
  23.         /**
  24.          * @ORM\Id
  25.          * @ORM\GeneratedValue
  26.          * @ORM\Column(type="integer")
  27.          */
  28.         private $id;
  29.         /**
  30.          * @ORM\Column(type="string", length=255)
  31.          */
  32.         private $name;
  33.         /**
  34.          * @ORM\Column(type="text")
  35.          */
  36.         private $description;
  37.         /**
  38.          * @ORM\Column(type="boolean", nullable=true)
  39.          */
  40.         private $isRandom;
  41.         /**
  42.          * @ORM\Column(type="integer",options={"default":0})
  43.          */
  44.         private $status 0;
  45.         /**
  46.          * @ORM\OneToMany(targetEntity=Question::class, mappedBy="quizz", cascade={"remove", "persist"})
  47.          */
  48.         private $questions;
  49.         public function __construct()
  50.         {
  51.             $this->questions = new ArrayCollection();
  52.         }
  53.         public function getId(): ?int
  54.         {
  55.             return $this->id;
  56.         }
  57.         public function getName(): ?string
  58.         {
  59.             return $this->name;
  60.         }
  61.         public function setNamestring $name ): self
  62.         {
  63.             $this->name $name;
  64.             return $this;
  65.         }
  66.         public function getDescription(): ?string
  67.         {
  68.             return $this->description;
  69.         }
  70.         public function setDescriptionstring $description ): self
  71.         {
  72.             $this->description $description;
  73.             return $this;
  74.         }
  75.         public function getIsRandom(): ?bool
  76.         {
  77.             return $this->isRandom;
  78.         }
  79.         public function setIsRandom( ?bool $isRandom ): self
  80.         {
  81.             $this->isRandom $isRandom;
  82.             return $this;
  83.         }
  84.         public function getStatus(): ?int
  85.         {
  86.             return $this->status;
  87.         }
  88.         public function setStatusint $status ): self
  89.         {
  90.             $this->status $status;
  91.             return $this;
  92.         }
  93.         /**
  94.          * @return Collection|Question[]
  95.          */
  96.         public function getQuestions(): Collection
  97.         {
  98.             return $this->questions;
  99.         }
  100.         public function addQuestionQuestion $question ): self
  101.         {
  102.             if ( !$this->questions->contains$question ) ) {
  103.                 $this->questions[] = $question;
  104.                 $question->setQuizz$this );
  105.             }
  106.             return $this;
  107.         }
  108.         public function removeQuestionQuestion $question ): self
  109.         {
  110.             if ( $this->questions->removeElement$question ) ) {
  111.                 // set the owning side to null (unless already changed)
  112.                 if ( $question->getQuizz() === $this ) {
  113.                     $question->setQuizzNULL );
  114.                 }
  115.             }
  116.             return $this;
  117.         }
  118.     }