src/Entity/Answere.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\AnswereRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassAnswereRepository::class)]
  10. #[ApiResource]
  11. class Answere
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(typeTypes::TEXT)]
  18.     private ?string $text null;
  19.     #[ORM\Column]
  20.     private ?bool $isRight null;
  21.     #[ORM\ManyToOne(inversedBy'answeres')]
  22.     private ?Question $question null;
  23.     #[ORM\OneToMany(mappedBy'answer'targetEntityGivenAnswere::class)]
  24.     private Collection $givenAnsweres;
  25.     public function __construct()
  26.     {
  27.         $this->givenAnsweres = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getText(): ?string
  34.     {
  35.         return $this->text;
  36.     }
  37.     public function setText(string $text): self
  38.     {
  39.         $this->text $text;
  40.         return $this;
  41.     }
  42.     public function isIsRight(): ?bool
  43.     {
  44.         return $this->isRight;
  45.     }
  46.     public function setIsRight(bool $isRight): self
  47.     {
  48.         $this->isRight $isRight;
  49.         return $this;
  50.     }
  51.     public function getQuestion(): ?Question
  52.     {
  53.         return $this->question;
  54.     }
  55.     public function setQuestion(?Question $question): self
  56.     {
  57.         $this->question $question;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, GivenAnswere>
  62.      */
  63.     public function getGivenAnsweres(): Collection
  64.     {
  65.         return $this->givenAnsweres;
  66.     }
  67.     public function addGivenAnswere(GivenAnswere $givenAnswere): self
  68.     {
  69.         if (!$this->givenAnsweres->contains($givenAnswere)) {
  70.             $this->givenAnsweres->add($givenAnswere);
  71.             $givenAnswere->setAnswer($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeGivenAnswere(GivenAnswere $givenAnswere): self
  76.     {
  77.         if ($this->givenAnsweres->removeElement($givenAnswere)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($givenAnswere->getAnswer() === $this) {
  80.                 $givenAnswere->setAnswer(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85. }