src/Entity/Proposition.php line 14
<?php
namespace App\Entity;
use App\Repository\PropositionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: PropositionRepository::class)]
class Proposition
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'propositions')]
#[ORM\JoinColumn(nullable: false)]
private ?Quiz $quiz = null;
#[ORM\Column(type: Types::TEXT)]
#[Assert\NotBlank(message: "Ne peut ĂȘtre vide !")]
#[Assert\NotNull(message: "Ne peut ĂȘtre nul !")]
private ?string $content = null;
#[ORM\Column]
private ?bool $isTrue = null;
#[ORM\OneToMany(mappedBy: 'proposition', targetEntity: Reponse::class, orphanRemoval: true)]
private Collection $reponses;
public function __construct()
{
$this->reponses = new ArrayCollection();
$this->isTrue = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getQuiz(): ?Quiz
{
return $this->quiz;
}
public function setQuiz(?Quiz $quiz): self
{
$this->quiz = $quiz;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function isIsTrue(): ?bool
{
return $this->isTrue;
}
public function setIsTrue(bool $isTrue): self
{
$this->isTrue = $isTrue;
return $this;
}
/**
* @return Collection<int, Reponse>
*/
public function getReponses(): Collection
{
return $this->reponses;
}
public function addReponse(Reponse $reponse): self
{
if (!$this->reponses->contains($reponse)) {
$this->reponses->add($reponse);
$reponse->setProposition($this);
}
return $this;
}
public function removeReponse(Reponse $reponse): self
{
if ($this->reponses->removeElement($reponse)) {
// set the owning side to null (unless already changed)
if ($reponse->getProposition() === $this) {
$reponse->setProposition(null);
}
}
return $this;
}
}