<?php
namespace App\Entity\Configuration;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use App\Repository\Configuration\OptionInSurveyRepository;
#[ORM\Entity(repositoryClass: OptionInSurveyRepository::class)]
class OptionInSurvey
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'optionInSurveys')]
#[ORM\JoinColumn(nullable: false)]
private ?Option $relatedOption = null;
#[ORM\ManyToOne(inversedBy: 'optionInSurveys')]
#[ORM\JoinColumn(nullable: false)]
private ?Survey $survey = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $mandatory = null;
#[ORM\Column(nullable: true)]
private ?int $position = null;
#[ORM\Column(nullable: true)]
private ?bool $isDisplay = true;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $deletedAt = null;
#[ORM\OneToMany(mappedBy: 'optionInSurvey', targetEntity: ConditionnedOption::class, orphanRemoval: true)]
private Collection $conditionnedOptions;
#[ORM\OneToMany(mappedBy: 'resultOptionInSurvey', targetEntity: ConditionnedOption::class, orphanRemoval: true)]
private Collection $conditionnedResult;
#[ORM\Column(nullable: true)]
private ?bool $isEnable = null;
#[ORM\OneToMany(mappedBy: 'optionInSurvey', targetEntity: ValueInSurvey::class, orphanRemoval: true)]
private Collection $valueInSurveys;
public function __construct()
{
$this->conditionnedOptions = new ArrayCollection();
$this->conditionnedResult = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->valueInSurveys = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getRelatedOption(): ?Option
{
return $this->relatedOption;
}
public function setRelatedOption(?Option $relatedOption): self
{
$this->relatedOption = $relatedOption;
return $this;
}
public function getSurvey(): ?Survey
{
return $this->survey;
}
public function setSurvey(?Survey $survey): self
{
$this->survey = $survey;
return $this;
}
public function getMandatory(): ?string
{
return $this->mandatory;
}
public function setMandatory(?string $mandatory): self
{
$this->mandatory = $mandatory;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
public function isIsDisplay(): ?bool
{
return $this->isDisplay;
}
public function setIsDisplay(?bool $isDisplay): self
{
$this->isDisplay = $isDisplay;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @return Collection<int, ConditionnedOption>
*/
public function getConditionnedOptions(): Collection
{
return $this->conditionnedOptions;
}
public function addConditionnedOption(ConditionnedOption $conditionnedOption): self
{
if (!$this->conditionnedOptions->contains($conditionnedOption)) {
$this->conditionnedOptions->add($conditionnedOption);
$conditionnedOption->setOptionInSurvey($this);
}
return $this;
}
public function removeConditionnedOption(ConditionnedOption $conditionnedOption): self
{
if ($this->conditionnedOptions->removeElement($conditionnedOption)) {
// set the owning side to null (unless already changed)
if ($conditionnedOption->getOptionInSurvey() === $this) {
$conditionnedOption->setOptionInSurvey(null);
}
}
return $this;
}
/**
* @return Collection<int, ConditionnedOption>
*/
public function getConditionnedResult(): Collection
{
return $this->conditionnedResult;
}
public function addConditionnedResult(ConditionnedOption $conditionnedResult): self
{
if (!$this->conditionnedResult->contains($conditionnedResult)) {
$this->conditionnedResult->add($conditionnedResult);
$conditionnedResult->setResultOptionInSurvey($this);
}
return $this;
}
public function removeConditionnedResult(ConditionnedOption $conditionnedResult): self
{
if ($this->conditionnedResult->removeElement($conditionnedResult)) {
// set the owning side to null (unless already changed)
if ($conditionnedResult->getResultOptionInSurvey() === $this) {
$conditionnedResult->setResultOptionInSurvey(null);
}
}
return $this;
}
public function isIsEnable(): ?bool
{
return $this->isEnable;
}
public function setIsEnable(?bool $isEnable): self
{
$this->isEnable = $isEnable;
return $this;
}
/**
* @return Collection<int, ValueInSurvey>
*/
public function getValueInSurveys(): Collection
{
return $this->valueInSurveys;
}
public function addValueInSurvey(ValueInSurvey $valueInSurvey): self
{
/* if (!$this->valueInSurveys->contains($valueInSurvey)) {
$this->valueInSurveys->add($valueInSurvey);
$valueInSurvey->setOptionInSurvey($this);
}*/
if (!$this->valueInSurveys->contains($valueInSurvey)) {
$this->valueInSurveys[] = $valueInSurvey;
$valueInSurvey->setOptionInSurvey($this);
}
return $this;
}
public function removeValueInSurvey(ValueInSurvey $valueInSurvey): self
{
if ($this->valueInSurveys->removeElement($valueInSurvey)) {
// set the owning side to null (unless already changed)
if ($valueInSurvey->getOptionInSurvey() === $this) {
$valueInSurvey->setOptionInSurvey(null);
}
}
return $this;
}
}