Film.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FilmRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Table(name: "film")]
  8. #[ORM\Entity(repositoryClass: FilmRepository::class)]
  9. class Film
  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: "titre", type: "string", length: 191)]
  16. private ?string $titre = null;
  17. #[ORM\Column(name: "annee", type: "date", nullable: true)]
  18. private ?\DateTimeInterface $annee = null;
  19. #[ORM\Column(name: "date_submited", type: "datetime", nullable: true)]
  20. private ?\DateTimeInterface $dateSubmited = null;
  21. #[ORM\Column(name: "lien", type: "string", length: 191, nullable: true)]
  22. #[Assert\Url()]
  23. private ?string $lien = null;
  24. #[ORM\Column(name: "note", type: "float", nullable: true)]
  25. private ?float $note = null;
  26. #[ORM\Column(name: "nb_coms", type: "integer", nullable: true)]
  27. private ?int $nbComs = null;
  28. #[Assert\Valid()]
  29. #[ORM\OneToOne(targetEntity: MediaVideo::class, cascade: ["persist","remove"])]
  30. #[ORM\JoinColumn(nullable: true)]
  31. private ?MediaVideo $mediaVideo = null;
  32. #[ORM\ManyToMany(targetEntity: Realisateur::class, inversedBy: "films", cascade: ["persist"])]
  33. private ?Collection $realisateurs = null;
  34. #[ORM\OneToMany(targetEntity: Commentaire::class, mappedBy: "film", orphanRemoval: true)]
  35. private ?Collection $commentaires = null;
  36. #[ORM\ManyToOne(targetEntity: User::class)]
  37. #[ORM\JoinColumn(nullable: true)]
  38. private ?User $authered = null;
  39. #[ORM\ManyToMany(targetEntity: User::class, inversedBy: "films")]
  40. #[ORM\JoinTable(name: "filmsavoir_users")]
  41. private ?Collection $usersWantToView = null;
  42. #[ORM\ManyToMany(targetEntity: User::class, inversedBy: "filmsVus")]
  43. #[ORM\JoinTable(name: "filmsvus_users")]
  44. private ?Collection $usersWhoSeen = null;
  45. #[ORM\ManyToMany(targetEntity: Genre::class, cascade: ["persist"])]
  46. private ?Collection $genres = null;
  47. #[ORM\Column(type: "text", nullable: true)]
  48. private ?string $information = null;
  49. #[ORM\Column(type: "date", nullable: true)]
  50. private ?\DateTimeInterface $dateSortie = null;
  51. public function __construct()
  52. {
  53. $this->realisateurs = new \Doctrine\Common\Collections\ArrayCollection();
  54. $this->usersWantToView = new \Doctrine\Common\Collections\ArrayCollection();
  55. $this->usersWhoSeen = new \Doctrine\Common\Collections\ArrayCollection();
  56. $this->genres = new \Doctrine\Common\Collections\ArrayCollection();
  57. $this->commentaires = new \Doctrine\Common\Collections\ArrayCollection();
  58. $this->setDateSubmited(new \DateTime());
  59. }
  60. public function getAuthered(): ?User
  61. {
  62. return $this->authered;
  63. }
  64. public function setAuthered(?User $authered): self
  65. {
  66. $this->authered = $authered;
  67. return $this;
  68. }
  69. public function getId(): ?int
  70. {
  71. return $this->id;
  72. }
  73. public function setTitre(?string $titre): self
  74. {
  75. $this->titre = $titre;
  76. return $this;
  77. }
  78. public function getTitre(): ?string
  79. {
  80. return $this->titre;
  81. }
  82. public function setAnnee(?\DateTimeInterface $annee): self
  83. {
  84. $this->annee = $annee;
  85. return $this;
  86. }
  87. public function getAnnee(): ?\DateTimeInterface
  88. {
  89. return $this->annee;
  90. }
  91. public function getLien(): ?string
  92. {
  93. return $this->lien;
  94. }
  95. public function setLien(?string $lien = null): self
  96. {
  97. $this->lien = $lien;
  98. return $this;
  99. }
  100. public function getDateSubmited(): ?\DateTimeInterface
  101. {
  102. return $this->dateSubmited;
  103. }
  104. public function setDateSubmited(?\DateTimeInterface $dateSubmited): self
  105. {
  106. $this->dateSubmited = $dateSubmited;
  107. return $this;
  108. }
  109. public function isNew(): ?bool
  110. {
  111. $finNew = (new \DateTime($this->getDateSubmited()->format("Y/m/d")))->modify('+1 day');
  112. return (new \DateTime('now') < $finNew);
  113. }
  114. public function addCommentaire(Commentaire $commentaire): self
  115. {
  116. $this->commentaires[] = $commentaire;
  117. return $this;
  118. }
  119. public function removeCommentaire(Commentaire $commentaire): self
  120. {
  121. $this->commentaires->removeElement($commentaire);
  122. return $this;
  123. }
  124. public function getCommentaires(): Collection
  125. {
  126. return $this->commentaires;
  127. }
  128. public function addRealisateur(Realisateur $realisateur): self
  129. {
  130. $this->realisateurs[] = $realisateur;
  131. return $this;
  132. }
  133. public function removeRealisateur(Realisateur $realisateur): self
  134. {
  135. $this->realisateurs->removeElement($realisateur);
  136. return $this;
  137. }
  138. public function getRealisateurs(): Collection
  139. {
  140. return $this->realisateurs;
  141. }
  142. public function addUserWantToView(User $user): self
  143. {
  144. $this->usersWantToView[] = $user;
  145. $user->addFilm($this);
  146. return $this;
  147. }
  148. public function removeUserWantToView(User $user): self
  149. {
  150. $this->usersWantToView->removeElement($user);
  151. $user->removeFilm($this);
  152. return $this;
  153. }
  154. public function getUsersWantToView(): Collection
  155. {
  156. return $this->usersWantToView;
  157. }
  158. public function addUserWhoSeen(User $user):self
  159. {
  160. $this->usersWhoSeen[] = $user;
  161. $user->addFilmVu($this);
  162. return $this;
  163. }
  164. public function removeUserWhoSeen(User $user): self
  165. {
  166. $this->usersWhoSeen->removeElement($user);
  167. $user->removeFilmVu($this);
  168. return $this;
  169. }
  170. public function getUsersWhoSeen(): Collection
  171. {
  172. return $this->usersWhoSeen;
  173. }
  174. public function getGenres(): Collection
  175. {
  176. return $this->genres;
  177. }
  178. public function addGenre(Genre $genre): self
  179. {
  180. $this->genres[] = $genre;
  181. return $this;
  182. }
  183. public function removeGenre(Genre $genre): self
  184. {
  185. $this->genres->removeElement($genre);
  186. return $this;
  187. }
  188. public function getNote(): ?float
  189. {
  190. return $this->note;
  191. }
  192. public function setNote(?float $note): self
  193. {
  194. $this->note = $note;
  195. return $this;
  196. }
  197. public function getNbComs(): ?int
  198. {
  199. return $this->nbComs;
  200. }
  201. public function setNbComs(?int $nbComs): self
  202. {
  203. $this->nbComs = $nbComs;
  204. return $this;
  205. }
  206. public function getInformation(): ?string
  207. {
  208. return $this->information;
  209. }
  210. public function setInformation(?string $information): self
  211. {
  212. $this->information = $information;
  213. return $this;
  214. }
  215. public function getDateSortie(): ?\DateTimeInterface
  216. {
  217. return $this->dateSortie;
  218. }
  219. public function setDateSortie(?\DateTimeInterface $dateSortie): self
  220. {
  221. $this->dateSortie = $dateSortie;
  222. return $this;
  223. }
  224. public function getMediaVideo(): ?MediaVideo
  225. {
  226. return $this->mediaVideo;
  227. }
  228. public function setMediaVideo(?MediaVideo $mediaVideo = null): self
  229. {
  230. $this->mediaVideo = $mediaVideo;
  231. return $this;
  232. }
  233. }