src/Entity/CRM/Survey.php line 11

  1. <?php
  2. // src/Entity/Survey.php
  3. namespace App\Entity\CRM;
  4. use App\Repository\SurveyRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSurveyRepository::class)]
  9. class Survey
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private ?int $id null;
  15.     #[ORM\Column(type'string'length150)]
  16.     private ?string $title null;
  17.     #[ORM\Column(type'text'nullabletrue)]
  18.     private ?string $description null;
  19.     #[ORM\OneToMany(mappedBy'survey'targetEntitySurveyQuestion::class, cascade: ['persist''remove'])]
  20.     private Collection $questions;
  21.     #[ORM\OneToMany(mappedBy'survey'targetEntitySurveyResponse::class, cascade: ['persist''remove'])]
  22.     private Collection $responses;
  23.     #[ORM\Column]
  24.     private ?bool $isActive null;
  25.     public function __construct()
  26.     {
  27.         $this->questions = new ArrayCollection();
  28.         $this->responses = new ArrayCollection();
  29.     }
  30.     public function __toString(): string
  31.     {
  32.         return $this->title;
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getTitle(): ?string
  39.     {
  40.         return $this->title;
  41.     }
  42.     public function setTitle(string $title): self
  43.     {
  44.         $this->title $title;
  45.         return $this;
  46.     }
  47.     public function getDescription(): ?string
  48.     {
  49.         return $this->description;
  50.     }
  51.     public function setDescription(?string $description): self
  52.     {
  53.         $this->description $description;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection|SurveyQuestion[]
  58.      */
  59.     public function getQuestions(): Collection
  60.     {
  61.         return $this->questions;
  62.     }
  63.     public function addQuestion(SurveyQuestion $question): self
  64.     {
  65.         if (!$this->questions->contains($question)) {
  66.             $this->questions[] = $question;
  67.             $question->setSurvey($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeQuestion(SurveyQuestion $question): self
  72.     {
  73.         if ($this->questions->removeElement($question)) {
  74.             // ustawienie relacji na null, jeśli to konieczne
  75.             if ($question->getSurvey() === $this) {
  76.                 $question->setSurvey(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection|SurveyResponse[]
  83.      */
  84.     public function getResponses(): Collection
  85.     {
  86.         return $this->responses;
  87.     }
  88.     public function addResponse(SurveyResponse $response): self
  89.     {
  90.         if (!$this->responses->contains($response)) {
  91.             $this->responses[] = $response;
  92.             $response->setSurvey($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeResponse(SurveyResponse $response): self
  97.     {
  98.         if ($this->responses->removeElement($response)) {
  99.             if ($response->getSurvey() === $this) {
  100.                 $response->setSurvey(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function isIsActive(): ?bool
  106.     {
  107.         return $this->isActive;
  108.     }
  109.     public function setIsActive(bool $isActive): static
  110.     {
  111.         $this->isActive $isActive;
  112.         return $this;
  113.     }
  114. }