HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Entity/Poll/AnswerRow.php
<?php

namespace App\Entity\Poll;

use App\Entity\Lecturer;
use App\Repository\Poll\AnswerRowRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * AnswerRow
 */
#[ORM\Table(name: 'poll_answer_row')]
#[ORM\Entity(repositoryClass: AnswerRowRepository::class)]
class AnswerRow
{
    #[ORM\Column]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\JoinColumn(name: 'poll_id', referencedColumnName: 'id', nullable: false)]
    #[ORM\ManyToOne(targetEntity: Poll::class, inversedBy: 'answerRows')]
    private ?Poll $poll;

    #[ORM\OneToMany(mappedBy: 'answerRow', targetEntity: Answer::class)]
    private Collection $answers;

    #[ORM\JoinColumn(name: 'lecturer_id', referencedColumnName: 'id', nullable: false)]
    #[ORM\ManyToOne(targetEntity: Lecturer::class, inversedBy: 'answerRows')]
    private ?Lecturer $lecturer;

    public function __construct()
    {
        $this->answers = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getPoll(): ?Poll
    {
        return $this->poll;
    }

    public function setPoll(?Poll $poll): static
    {
        $this->poll = $poll;

        return $this;
    }

    /**
     * @return Collection<int, Answer>
     */
    public function getAnswers(): Collection
    {
        return $this->answers;
    }

    public function setAnswers($answers)
    {
        $this->answers = $answers;
        return $this;
    }

    public function getLecturer(): ?Lecturer
    {
        return $this->lecturer;
    }

    public function setLecturer(?Lecturer $lecturer): static
    {
        $this->lecturer = $lecturer;

        return $this;
    }

    public function addAnswer(Answer $answer): static
    {
        if (!$this->answers->contains($answer)) {
            $this->answers->add($answer);
            $answer->setAnswerRow($this);
        }

        return $this;
    }

    public function removeAnswer(Answer $answer): static
    {
        if ($this->answers->removeElement($answer)) {
            // set the owning side to null (unless already changed)
            if ($answer->getAnswerRow() === $this) {
                $answer->setAnswerRow(null);
            }
        }

        return $this;
    }
}