<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use App\Repository\IdeaBoxRatingRepository;
/**
* @ORM\Entity(repositoryClass=IdeaBoxRatingRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*/
class IdeaBoxRating
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({
* "idea_box_rating:id",
* "idea_box_stats", "export_idea_box_datatable"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=IdeaBox::class, inversedBy="ideaBoxRatings")
* @ORM\JoinColumn(nullable=false)
*
* @Expose
* @Groups({
* "idea_box_rating:idea_box",
* "export_idea_box_datatable"
* })
*/
private ?IdeaBox $ideaBox;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="ideaBoxRatings")
* @ORM\JoinColumn(nullable=false)
*
* @Expose
* @Groups({
* "idea_box_rating:user",
* "export_idea_box_datatable"
* })
*/
private ?User $user;
/** use Doctrine\ORM\PersistentCollection as ArrayCollection;
* @ORM\Column(type="integer", nullable=true)
*
* @Expose
* @Groups({
* "idea_box_rating:rate",
* "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Assert\Range(
* min = 1,
* max = 5,
* notInRangeMessage = "La valeur pour 'rate' doit ĂȘtre comprise entre {{ min }} et {{ max }}",
* )
*/
private ?int $rate;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Expose
* @Groups({
* "idea_box_rating:opinion",
* "idea_box_stats", "export_idea_box_datatable"
* })
*/
private ?string $opinion;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxRating", cascade={"persist"})
*
* @Expose
* @Groups({
* "idea_box_rating:idea_box_recipients",
* "export_idea_box_datatable"
* })
*/
private $ideaBoxRecipients;
public function __construct()
{
$this->ideaBoxRecipients = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdeaBox(): ?IdeaBox
{
return $this->ideaBox;
}
public function setIdeaBox( ?IdeaBox $ideaBox ): self
{
$this->ideaBox = $ideaBox;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser( ?User $user ): self
{
$this->user = $user;
return $this;
}
public function getRate(): ?int
{
return $this->rate;
}
public function setRate( ?int $rate ): IdeaBoxRating
{
$this->rate = $rate;
return $this;
}
public function getOpinion(): ?string
{
return $this->opinion;
}
public function setOpinion( $opinion ): IdeaBoxRating
{
$this->opinion = $opinion;
return $this;
}
public function getIdeaBoxRecipients(): Collection
{
return $this->ideaBoxRecipients;
}
public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxRating
{
if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
$this->ideaBoxRecipients[] = $ideaBoxRecipient;
$ideaBoxRecipient->setIdeaBoxRating( $this );
}
return $this;
}
public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxRating
{
if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
// set the owning side to null (unless already changed)
if ( $ideaBoxRecipient->getIdeaBoxRating() === $this ) {
$ideaBoxRecipient->setIdeaBoxRating( NULL );
}
}
return $this;
}
}