<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Symfony\Component\Serializer\Annotation\Ignore;
/**
* PollOption
*
* @ORM\Table(name="poll_option")
* @ORM\Entity(repositoryClass="App\Repository\PollOptionRepository")
*/
class PollOption
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\Column(name="description", type="string", length=255)
*/
private string $description;
/**
*
* @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="pollOptions")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="poll_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* })
*/
#[Ignore]
private Poll $poll;
/**
* @var Collection<int, Flat>
* @ORM\ManyToMany(targetEntity="App\Entity\Flat", inversedBy="votedOptions")
* @ORM\JoinTable(name="poll_options_flats")
*/
private Collection $pollOptionsFlats;
/**
* PollOption constructor.
*/
public function __construct()
{
$this->pollOptionsFlats = new ArrayCollection();
}
/**
* @param Flat $flat
*/
public function addFlatVote(Flat $flat): void
{
$this->pollOptionsFlats[] = $flat;
}
/**
* @param Flat $flat
*/
public function removeFlatVote(Flat $flat): void
{
if (!$this->pollOptionsFlats->contains($flat)) {
return;
}
$this->pollOptionsFlats->removeElement($flat);
$flat->removePollOption($this);
}
/**
* Get id
*
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* @return Poll
*/
public function getPoll(): Poll
{
return $this->poll;
}
/**
* @param Poll $poll
*/
public function setPoll(Poll $poll): void
{
$this->poll = $poll;
}
/**
* @return Collection<int, Flat>
*/
public function getPollOptionsFlats(): Collection
{
return $this->pollOptionsFlats;
}
/**
* @param Collection<int, Flat> $pollOptionsFlats
*/
public function setPollOptionsFlats(Collection $pollOptionsFlats): void
{
$this->pollOptionsFlats = $pollOptionsFlats;
}
public function __toString()
{
return (string) $this->getDescription();
}
}