<?php
namespace App\Entity\Configuration;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\Configuration\OptionRepository;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: OptionRepository::class)]
#[ORM\Table(name: '`option`')]
class Option
{
use TimestampableEntity;
const TYPE_RADIO = "radio";
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $deletedAt = null;
#[ORM\Column(nullable: true)]
private ?bool $isEnable = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\OneToMany(mappedBy: 'relatedOption', targetEntity: OptionValue::class, orphanRemoval: true)]
private Collection $optionValues;
#[ORM\OneToMany(mappedBy: 'relatedOption', targetEntity: OptionInSurvey::class, orphanRemoval: true)]
private Collection $optionInSurveys;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->optionValues = new ArrayCollection();
$this->optionInSurveys = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function isIsEnable(): ?bool
{
return $this->isEnable;
}
public function setIsEnable(?bool $isEnable): self
{
$this->isEnable = $isEnable;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, OptionValue>
*/
public function getOptionValues(): Collection
{
return $this->optionValues;
}
public function addOptionValue(OptionValue $optionValue): self
{
if (!$this->optionValues->contains($optionValue)) {
$this->optionValues->add($optionValue);
$optionValue->setRelatedOption($this);
}
return $this;
}
public function removeOptionValue(OptionValue $optionValue): self
{
if ($this->optionValues->removeElement($optionValue)) {
// set the owning side to null (unless already changed)
if ($optionValue->getRelatedOption() === $this) {
$optionValue->setRelatedOption(null);
}
}
return $this;
}
/**
* @return Collection<int, OptionInSurvey>
*/
public function getOptionInSurveys(): Collection
{
return $this->optionInSurveys;
}
public function addOptionInSurvey(OptionInSurvey $optionInSurvey): self
{
if (!$this->optionInSurveys->contains($optionInSurvey)) {
$this->optionInSurveys->add($optionInSurvey);
$optionInSurvey->setRelatedOption($this);
}
return $this;
}
public function removeOptionInSurvey(OptionInSurvey $optionInSurvey): self
{
if ($this->optionInSurveys->removeElement($optionInSurvey)) {
// set the owning side to null (unless already changed)
if ($optionInSurvey->getRelatedOption() === $this) {
$optionInSurvey->setRelatedOption(null);
}
}
return $this;
}
}