<?php
namespace App\Entity\Configuration;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Request\RequestForm;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use App\Repository\Configuration\SurveyRepository;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: SurveyRepository::class)]
#[UniqueEntity(
fields: ['refSuffix'],
errorPath: 'refSuffix',
message: 'This refSuffix is already in use',
)]
class Survey
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?bool $isEnable = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $deletedAt = null;
#[ORM\Column(nullable: true)]
private ?bool $isDisplay = null;
#[ORM\Column(length: 255, nullable: false, unique: true)]
private ?string $refSuffix;
#[ORM\OneToMany(mappedBy: 'survey', targetEntity: OptionInSurvey::class)]
private Collection $optionInSurveys;
#[ORM\OneToMany(mappedBy: 'survey', targetEntity: RequestForm::class, orphanRemoval: true)]
private Collection $requestForms;
#[ORM\Column(length: 50, nullable: true)]
private ?string $bgColor = null;
#[ORM\Column(nullable: true)]
private ?int $position = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $surveyColor = null;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->optionInSurveys = new ArrayCollection();
$this->requestForms = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function isIsEnable(): ?bool
{
return $this->isEnable;
}
public function setIsEnable(?bool $isEnable): self
{
$this->isEnable = $isEnable;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function isIsDisplay(): ?bool
{
return $this->isDisplay;
}
public function setIsDisplay(?bool $isDisplay): self
{
$this->isDisplay = $isDisplay;
return $this;
}
public function getRefSuffix(): ?string
{
return $this->refSuffix;
}
public function setRefSuffix(?string $refSuffix): self
{
$this->refSuffix = $refSuffix;
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->setSurvey($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->getSurvey() === $this) {
$optionInSurvey->setSurvey(null);
}
}
return $this;
}
/**
* @return Collection<int, RequestForm>
*/
public function getRequestForms(): Collection
{
return $this->requestForms;
}
public function addRequestForm(RequestForm $requestForm): self
{
if (!$this->requestForms->contains($requestForm)) {
$this->requestForms->add($requestForm);
$requestForm->setSurvey($this);
}
return $this;
}
public function removeRequestForm(RequestForm $requestForm): self
{
if ($this->requestForms->removeElement($requestForm)) {
// set the owning side to null (unless already changed)
if ($requestForm->getSurvey() === $this) {
$requestForm->setSurvey(null);
}
}
return $this;
}
public function getBgColor(): ?string
{
return $this->bgColor;
}
public function setBgColor(?string $bgColor): static
{
$this->bgColor = $bgColor;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): static
{
$this->position = $position;
return $this;
}
public function getSurveyColor(): ?string
{
return $this->surveyColor;
}
public function setSurveyColor(?string $surveyColor): static
{
$this->surveyColor = $surveyColor;
return $this;
}
}