src/Entity/CRM/SurveyQuestion.php line 11

  1. <?php
  2. // src/Entity/SurveyQuestion.php
  3. namespace App\Entity\CRM;
  4. use App\Repository\SurveyQuestionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSurveyQuestionRepository::class)]
  9. class SurveyQuestion
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private ?int $id null;
  15.     #[ORM\Column(type'text')]
  16.     private ?string $questionText null;
  17.     #[ORM\ManyToOne(targetEntitySurvey::class, inversedBy'questions')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private ?Survey $survey null;
  20.     #[ORM\Column]
  21.     private ?bool $isActive null;
  22.     #[ORM\OneToMany(mappedBy'surveyQuestion'targetEntitySurveyResponse::class)]
  23.     private Collection $surveyResponses;
  24.     public function __construct()
  25.     {
  26.         $this->surveyResponses = new ArrayCollection();
  27.     }
  28.     public function __toString(): string
  29.     {
  30.         return $this->questionText;
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getQuestionText(): ?string
  37.     {
  38.         return $this->questionText;
  39.     }
  40.     public function setQuestionText(string $questionText): self
  41.     {
  42.         $this->questionText $questionText;
  43.         return $this;
  44.     }
  45.     public function getSurvey(): ?Survey
  46.     {
  47.         return $this->survey;
  48.     }
  49.     public function setSurvey(?Survey $survey): self
  50.     {
  51.         $this->survey $survey;
  52.         return $this;
  53.     }
  54.     public function isIsActive(): ?bool
  55.     {
  56.         return $this->isActive;
  57.     }
  58.     public function setIsActive(bool $isActive): static
  59.     {
  60.         $this->isActive $isActive;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, SurveyResponse>
  65.      */
  66.     public function getSurveyResponses(): Collection
  67.     {
  68.         return $this->surveyResponses;
  69.     }
  70.     public function addSurveyResponse(SurveyResponse $surveyResponse): static
  71.     {
  72.         if (!$this->surveyResponses->contains($surveyResponse)) {
  73.             $this->surveyResponses->add($surveyResponse);
  74.             $surveyResponse->setSurveyQuestion($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeSurveyResponse(SurveyResponse $surveyResponse): static
  79.     {
  80.         if ($this->surveyResponses->removeElement($surveyResponse)) {
  81.             // set the owning side to null (unless already changed)
  82.             if ($surveyResponse->getSurveyQuestion() === $this) {
  83.                 $surveyResponse->setSurveyQuestion(null);
  84.             }
  85.         }
  86.         return $this;
  87.     }
  88. }