src/Entity/IdeaBoxRating.php line 19

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 JMS\Serializer\Annotation as Serializer;
  7. use JMS\Serializer\Annotation\Expose;
  8. use JMS\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use App\Repository\IdeaBoxRatingRepository;
  11. /**
  12. * @ORM\Entity(repositoryClass=IdeaBoxRatingRepository::class)
  13. *
  14. * @Serializer\ExclusionPolicy("ALL")
  15. */
  16. class IdeaBoxRating
  17. {
  18. /**
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. * @ORM\Column(type="integer")
  22. *
  23. * @Expose
  24. * @Groups({
  25. * "idea_box_rating:id",
  26. * "idea_box_stats", "export_idea_box_datatable"
  27. * })
  28. */
  29. private $id;
  30. /**
  31. * @ORM\ManyToOne(targetEntity=IdeaBox::class, inversedBy="ideaBoxRatings")
  32. * @ORM\JoinColumn(nullable=false)
  33. *
  34. * @Expose
  35. * @Groups({
  36. * "idea_box_rating:idea_box",
  37. * "export_idea_box_datatable"
  38. * })
  39. */
  40. private ?IdeaBox $ideaBox;
  41. /**
  42. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="ideaBoxRatings")
  43. * @ORM\JoinColumn(nullable=false)
  44. *
  45. * @Expose
  46. * @Groups({
  47. * "idea_box_rating:user",
  48. * "export_idea_box_datatable"
  49. * })
  50. */
  51. private ?User $user;
  52. /** use Doctrine\ORM\PersistentCollection as ArrayCollection;
  53. * @ORM\Column(type="integer", nullable=true)
  54. *
  55. * @Expose
  56. * @Groups({
  57. * "idea_box_rating:rate",
  58. * "idea_box_stats", "export_idea_box_datatable"
  59. * })
  60. *
  61. * @Assert\Range(
  62. * min = 1,
  63. * max = 5,
  64. * notInRangeMessage = "La valeur pour 'rate' doit ĂȘtre comprise entre {{ min }} et {{ max }}",
  65. * )
  66. */
  67. private ?int $rate;
  68. /**
  69. * @ORM\Column(type="text", nullable=true)
  70. *
  71. * @Expose
  72. * @Groups({
  73. * "idea_box_rating:opinion",
  74. * "idea_box_stats", "export_idea_box_datatable"
  75. * })
  76. */
  77. private ?string $opinion;
  78. /**
  79. * @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxRating", cascade={"persist"})
  80. *
  81. * @Expose
  82. * @Groups({
  83. * "idea_box_rating:idea_box_recipients",
  84. * "export_idea_box_datatable"
  85. * })
  86. */
  87. private $ideaBoxRecipients;
  88. public function __construct()
  89. {
  90. $this->ideaBoxRecipients = new ArrayCollection();
  91. }
  92. public function getId(): ?int
  93. {
  94. return $this->id;
  95. }
  96. public function getIdeaBox(): ?IdeaBox
  97. {
  98. return $this->ideaBox;
  99. }
  100. public function setIdeaBox( ?IdeaBox $ideaBox ): self
  101. {
  102. $this->ideaBox = $ideaBox;
  103. return $this;
  104. }
  105. public function getUser(): ?User
  106. {
  107. return $this->user;
  108. }
  109. public function setUser( ?User $user ): self
  110. {
  111. $this->user = $user;
  112. return $this;
  113. }
  114. public function getRate(): ?int
  115. {
  116. return $this->rate;
  117. }
  118. public function setRate( ?int $rate ): IdeaBoxRating
  119. {
  120. $this->rate = $rate;
  121. return $this;
  122. }
  123. public function getOpinion(): ?string
  124. {
  125. return $this->opinion;
  126. }
  127. public function setOpinion( $opinion ): IdeaBoxRating
  128. {
  129. $this->opinion = $opinion;
  130. return $this;
  131. }
  132. public function getIdeaBoxRecipients(): Collection
  133. {
  134. return $this->ideaBoxRecipients;
  135. }
  136. public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxRating
  137. {
  138. if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
  139. $this->ideaBoxRecipients[] = $ideaBoxRecipient;
  140. $ideaBoxRecipient->setIdeaBoxRating( $this );
  141. }
  142. return $this;
  143. }
  144. public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxRating
  145. {
  146. if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
  147. // set the owning side to null (unless already changed)
  148. if ( $ideaBoxRecipient->getIdeaBoxRating() === $this ) {
  149. $ideaBoxRecipient->setIdeaBoxRating( NULL );
  150. }
  151. }
  152. return $this;
  153. }
  154. }