src/Entity/PollOption.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
  7. use Symfony\Component\Serializer\Annotation\Ignore;
  8. /**
  9.  * PollOption
  10.  *
  11.  * @ORM\Table(name="poll_option")
  12.  * @ORM\Entity(repositoryClass="App\Repository\PollOptionRepository")
  13.  */
  14. class PollOption
  15. {
  16.     /**
  17.      * @ORM\Column(name="id", type="integer")
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private int $id;
  22.     /**
  23.      * @ORM\Column(name="description", type="string", length=255)
  24.      */
  25.     private string $description;
  26.     /**
  27.      *
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="pollOptions")
  29.      * @ORM\JoinColumns({
  30.      *   @ORM\JoinColumn(name="poll_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  31.      * })
  32.      */
  33.     #[Ignore]
  34.     private Poll $poll;
  35.     /**
  36.      * @var Collection<int, Flat>
  37.      * @ORM\ManyToMany(targetEntity="App\Entity\Flat", inversedBy="votedOptions")
  38.      * @ORM\JoinTable(name="poll_options_flats")
  39.      */
  40.     private Collection $pollOptionsFlats;
  41.     /**
  42.      * PollOption constructor.
  43.      */
  44.     public function __construct()
  45.     {
  46.         $this->pollOptionsFlats = new ArrayCollection();
  47.     }
  48.     /**
  49.      * @param Flat $flat
  50.      */
  51.     public function addFlatVote(Flat $flat): void
  52.     {
  53.         $this->pollOptionsFlats[] = $flat;
  54.     }
  55.     /**
  56.      * @param Flat $flat
  57.      */
  58.     public function removeFlatVote(Flat $flat): void
  59.     {
  60.         if (!$this->pollOptionsFlats->contains($flat)) {
  61.             return;
  62.         }
  63.         $this->pollOptionsFlats->removeElement($flat);
  64.         $flat->removePollOption($this);
  65.     }
  66.     /**
  67.      * Get id
  68.      *
  69.      * @return int
  70.      */
  71.     public function getId(): int
  72.     {
  73.         return $this->id;
  74.     }
  75.     /**
  76.      * @return string
  77.      */
  78.     public function getDescription(): string
  79.     {
  80.         return $this->description;
  81.     }
  82.     /**
  83.      * @param string $description
  84.      */
  85.     public function setDescription(string $description): void
  86.     {
  87.         $this->description $description;
  88.     }
  89.     /**
  90.      * @return Poll
  91.      */
  92.     public function getPoll(): Poll
  93.     {
  94.         return $this->poll;
  95.     }
  96.     /**
  97.      * @param Poll $poll
  98.      */
  99.     public function setPoll(Poll $poll): void
  100.     {
  101.         $this->poll $poll;
  102.     }
  103.     /**
  104.      * @return Collection<int, Flat>
  105.      */
  106.     public function getPollOptionsFlats(): Collection
  107.     {
  108.         return $this->pollOptionsFlats;
  109.     }
  110.     /**
  111.      * @param Collection<int, Flat> $pollOptionsFlats
  112.      */
  113.     public function setPollOptionsFlats(Collection $pollOptionsFlats): void
  114.     {
  115.         $this->pollOptionsFlats $pollOptionsFlats;
  116.     }
  117.     public function __toString()
  118.     {
  119.         return (string) $this->getDescription();
  120.     }
  121. }