<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use App\Repository\IdeaBoxAnswerRepository;
/**
* @ORM\Entity(repositoryClass=IdeaBoxAnswerRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*/
class IdeaBoxAnswer
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({
* "idea_box_answer:id",
* "idea_box_stats", "export_idea_box_datatable"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=IdeaBoxQuestion::class, inversedBy="answers")
*
* @Expose
* @Groups({
* "idea_box_answer:idea_box_question",
* "export_idea_box_datatable"
* })
*/
private ?IdeaBoxQuestion $ideaBoxQuestion;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="ideaBoxAnswers")
* @ORM\JoinColumn(nullable=false)
*
* @Expose
* @Groups({
* "idea_box_answer:user",
* "export_idea_box_datatable"
* })
*/
private $user;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Expose
* @Groups({
* "idea_box_answer:answer",
* "idea_box_stats", "export_idea_box_datatable"
* })
*/
private ?string $answer;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxAnswer")
*
* @Expose
* @Groups({
* "idea_box_answer:idea_box_recipients",
* "export_idea_box_datatable"
* })
*/
private $ideaBoxRecipients;
public function __construct()
{
$this->user = new ArrayCollection();
$this->ideaBoxRecipients = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdeaBoxQuestion(): ?IdeaBoxQuestion
{
return $this->ideaBoxQuestion;
}
public function setIdeaBoxQuestion( ?IdeaBoxQuestion $ideaBoxQuestion ): self
{
$this->ideaBoxQuestion = $ideaBoxQuestion;
return $this;
}
public function getUser(): ArrayCollection
{
return $this->user;
}
public function setUser( ?User $user ): IdeaBoxAnswer
{
$this->user = $user;
return $this;
}
public function getAnswer(): ?string
{
return $this->answer;
}
public function setAnswer( ?string $answer ): IdeaBoxAnswer
{
$this->answer = $answer;
return $this;
}
public function getIdeaBoxRecipients()
{
return $this->ideaBoxRecipients;
}
public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxAnswer
{
if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
$this->ideaBoxRecipients[] = $ideaBoxRecipient;
$ideaBoxRecipient->setIdeaBoxAnswer( $this );
}
return $this;
}
public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxAnswer
{
if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
// set the owning side to null (unless already changed)
if ( $ideaBoxRecipient->getIdeaBoxAnswer() === $this ) {
$ideaBoxRecipient->setIdeaBoxAnswer( NULL );
}
}
return $this;
}
}