Commentaire.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentaireRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Table(name: "commentaire")]
  8. #[ORM\Entity(repositoryClass: CommentaireRepository::class)]
  9. class Commentaire
  10. {
  11. #[ORM\Column(name: "id", type: "integer")]
  12. #[ORM\Id]
  13. #[ORM\GeneratedValue(strategy: "AUTO")]
  14. private ?int $id = null;
  15. #[ORM\Column(name: "contenu", type: Types::TEXT, nullable: true)]
  16. private ?string $contenu = null;
  17. #[ORM\Column(name: "note", type: "integer", nullable: true)]
  18. #[Assert\Range(min: 1, max: 5, notInRangeMessage: "La note doit être comprise entre {{ min }} et {{ max }}.")]
  19. private ?int $note = null;
  20. #[ORM\ManyToOne(targetEntity: Film::class, inversedBy: "commentaires")]
  21. #[ORM\JoinColumn(nullable: false)]
  22. private ?Film $film = null;
  23. #[ORM\ManyToOne(targetEntity: User::class)]
  24. #[ORM\JoinColumn(nullable: false)]
  25. private ?User $user = null;
  26. #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
  27. private ?\DateTimeInterface $dateSubmitted = null;
  28. public function __construct ()
  29. {
  30. $this->dateSubmitted = new \DateTime('now');
  31. }
  32. public function getId(): ?int
  33. {
  34. return $this->id;
  35. }
  36. public function setContenu(?string $contenu): self
  37. {
  38. $this->contenu = $contenu;
  39. return $this;
  40. }
  41. public function getContenu(): ?string
  42. {
  43. return $this->contenu;
  44. }
  45. public function getNote(): ?int
  46. {
  47. return $this->note;
  48. }
  49. public function setNote(?int $note): self
  50. {
  51. $this->note = $note;
  52. return $this;
  53. }
  54. public function setFilm(?Film $film): self
  55. {
  56. $this->film = $film;
  57. return $this;
  58. }
  59. public function getFilm(): ?Film
  60. {
  61. return $this->film;
  62. }
  63. public function setUser(?User $user): self
  64. {
  65. $this->user = $user;
  66. return $this;
  67. }
  68. public function getUser(): ?User
  69. {
  70. return $this->user;
  71. }
  72. public function getDateSubmitted(): ?\DateTimeInterface
  73. {
  74. return $this->dateSubmitted;
  75. }
  76. public function setDateSubmitted(?\DateTimeInterface $dateSubmitted): self
  77. {
  78. $this->dateSubmitted = $dateSubmitted;
  79. return $this;
  80. }
  81. }