Event.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\Categories;
  6. use App\Entity\Core\File;
  7. use App\Entity\Organization\Organization;
  8. use App\Entity\Place\Place;
  9. use App\Entity\Place\PlaceSystem;
  10. use App\Entity\Place\Room;
  11. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  12. use App\Enum\Booking\PricingEventEnum;
  13. use App\Enum\Booking\VisibilityEnum;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. /**
  19. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Event, et supprimer l'attribut discr.
  20. * @todo : migration table tag_booking
  21. *
  22. * Évènement, rencontre
  23. */
  24. #[ApiResource(operations: [])]
  25. // #[Auditable]
  26. #[ORM\Entity]
  27. class Event extends AbstractBooking
  28. {
  29. #[ORM\ManyToOne(inversedBy: 'events')]
  30. #[ORM\JoinColumn(nullable: false)]
  31. protected Organization $organization;
  32. #[ORM\ManyToOne(inversedBy: 'events')]
  33. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  34. protected ?Place $place;
  35. #[ORM\ManyToOne(inversedBy: 'events')]
  36. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  37. protected ?Room $room = null;
  38. /** @var Collection<int, EventRecur> */
  39. #[ORM\OneToMany(targetEntity: EventRecur::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
  40. protected Collection $eventRecur;
  41. /** @var Collection<int, Event> */
  42. #[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'parent', cascade: ['persist'])]
  43. protected Collection $timeline;
  44. #[ORM\ManyToOne(targetEntity: Event::class, cascade: ['persist'], inversedBy: 'timeline')]
  45. #[ORM\JoinColumn(nullable: true)]
  46. protected ?Event $parent;
  47. #[Assert\Valid]
  48. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'events')]
  49. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  50. protected ?File $image;
  51. #[ORM\ManyToOne]
  52. protected ?EventGender $gender;
  53. /** @var Collection<int, EventUser> */
  54. #[Assert\Valid]
  55. #[ORM\OneToMany(targetEntity: EventUser::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
  56. protected Collection $eventUser;
  57. /** @var Collection<int, Categories> */
  58. #[ORM\ManyToMany(targetEntity: Categories::class, cascade: ['persist'])]
  59. protected Collection $categories;
  60. /** @var Collection<int, EventReport> */
  61. #[ORM\OneToMany(targetEntity: EventReport::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
  62. protected Collection $eventReports;
  63. /** @var Collection<int, File> */
  64. #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
  65. #[ORM\JoinTable(name: 'event_files')]
  66. #[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id', onDelete: 'cascade')]
  67. #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
  68. protected Collection $files;
  69. #[ORM\ManyToOne]
  70. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  71. protected ?PlaceSystem $placeSystem;
  72. /** @var Collection<int, AttendanceBooking> */
  73. #[ORM\OneToMany(targetEntity: AttendanceBooking::class, mappedBy: 'event', cascade: ['persist', 'remove'])]
  74. protected Collection $attendanceBooking;
  75. #[ORM\Column(type: 'text', nullable: true)]
  76. protected ?string $description;
  77. #[ORM\Column(nullable: true)]
  78. #[Assert\Url(
  79. message: 'url-error',
  80. protocols: ['http', 'https']
  81. )]
  82. protected ?string $url = null;
  83. #[ORM\Column(nullable: true)]
  84. #[Assert\Url(
  85. message: 'url-ticket-error',
  86. protocols: ['http', 'https']
  87. )]
  88. protected ?string $urlTicket = null;
  89. #[ORM\Column(length: 255, nullable: true, enumType: PricingEventEnum::class)]
  90. private ?PricingEventEnum $pricing = null;
  91. #[ORM\Column(nullable: true)]
  92. #[Assert\Positive]
  93. protected ?float $priceMini = null;
  94. #[ORM\Column(nullable: true)]
  95. #[Assert\Positive]
  96. protected ?float $priceMaxi = null;
  97. #[ORM\Column(length: 255, nullable: false, enumType: VisibilityEnum::class)]
  98. protected VisibilityEnum $visibility;
  99. public function __construct()
  100. {
  101. $this->eventRecur = new ArrayCollection();
  102. $this->timeline = new ArrayCollection();
  103. $this->eventUser = new ArrayCollection();
  104. $this->categories = new ArrayCollection();
  105. $this->eventReports = new ArrayCollection();
  106. $this->files = new ArrayCollection();
  107. $this->attendanceBooking = new ArrayCollection();
  108. $this->organizer = new ArrayCollection();
  109. $this->equipments = new ArrayCollection();
  110. parent::__construct();
  111. }
  112. public function getOrganization(): ?Organization
  113. {
  114. return $this->organization;
  115. }
  116. public function setOrganization(?Organization $organization): self
  117. {
  118. $this->organization = $organization;
  119. return $this;
  120. }
  121. public function getPlace(): ?Place
  122. {
  123. return $this->place;
  124. }
  125. public function setPlace(?Place $place): self
  126. {
  127. $this->place = $place;
  128. return $this;
  129. }
  130. public function getRoom(): ?Room
  131. {
  132. return $this->room;
  133. }
  134. public function setRoom(?Room $room): self
  135. {
  136. $this->room = $room;
  137. return $this;
  138. }
  139. /**
  140. * @return Collection<int, EventRecur>
  141. */
  142. public function getEventRecur(): Collection
  143. {
  144. return $this->eventRecur;
  145. }
  146. public function addEventRecur(EventRecur $eventRecur): self
  147. {
  148. if (!$this->eventRecur->contains($eventRecur)) {
  149. $this->eventRecur[] = $eventRecur;
  150. $eventRecur->setEvent($this);
  151. }
  152. return $this;
  153. }
  154. public function removeEventRecur(EventRecur $eventRecur): self
  155. {
  156. if ($this->eventRecur->removeElement($eventRecur)) {
  157. // set the owning side to null (unless already changed)
  158. if ($eventRecur->getEvent() === $this) {
  159. $eventRecur->setEvent(null);
  160. }
  161. }
  162. return $this;
  163. }
  164. /**
  165. * @return Collection<int, Event>
  166. */
  167. public function getTimeline(): Collection
  168. {
  169. return $this->timeline;
  170. }
  171. public function addTimeline(Event $timeline): self
  172. {
  173. if (!$this->timeline->contains($timeline)) {
  174. $this->timeline[] = $timeline;
  175. $timeline->setParent($this);
  176. }
  177. return $this;
  178. }
  179. public function removeTimeline(Event $timeline): self
  180. {
  181. if ($this->timeline->removeElement($timeline)) {
  182. // set the owning side to null (unless already changed)
  183. if ($timeline->getParent() === $this) {
  184. $timeline->setParent(null);
  185. }
  186. }
  187. return $this;
  188. }
  189. public function getParent(): ?self
  190. {
  191. return $this->parent;
  192. }
  193. public function setParent(?self $parent): self
  194. {
  195. $this->parent = $parent;
  196. return $this;
  197. }
  198. public function getImage(): ?File
  199. {
  200. return $this->image;
  201. }
  202. public function setImage(?File $image): self
  203. {
  204. $this->image = $image;
  205. return $this;
  206. }
  207. public function getGender(): ?EventGender
  208. {
  209. return $this->gender;
  210. }
  211. public function setGender(?EventGender $gender): self
  212. {
  213. $this->gender = $gender;
  214. return $this;
  215. }
  216. /**
  217. * @return Collection<int, EventUser>
  218. */
  219. public function getEventUser(): Collection
  220. {
  221. return $this->eventUser;
  222. }
  223. public function addEventUser(EventUser $eventUser): self
  224. {
  225. if (!$this->eventUser->contains($eventUser)) {
  226. $this->eventUser[] = $eventUser;
  227. $eventUser->setEvent($this);
  228. }
  229. return $this;
  230. }
  231. public function removeEventUser(EventUser $eventUser): self
  232. {
  233. if ($this->eventUser->removeElement($eventUser)) {
  234. // set the owning side to null (unless already changed)
  235. if ($eventUser->getEvent() === $this) {
  236. $eventUser->setEvent(null);
  237. }
  238. }
  239. return $this;
  240. }
  241. /**
  242. * @return Collection<int, Categories>
  243. */
  244. public function getCategories(): Collection
  245. {
  246. return $this->categories;
  247. }
  248. public function addCategory(Categories $category): self
  249. {
  250. if (!$this->categories->contains($category)) {
  251. $this->categories[] = $category;
  252. }
  253. return $this;
  254. }
  255. public function removeCategory(Categories $category): self
  256. {
  257. $this->categories->removeElement($category);
  258. return $this;
  259. }
  260. public function removeAllCategories(): self
  261. {
  262. foreach ($this->categories as $category) {
  263. $this->removeCategory($category);
  264. }
  265. return $this;
  266. }
  267. /**
  268. * @return Collection<int, EventReport>
  269. */
  270. public function getEventReports(): Collection
  271. {
  272. return $this->eventReports;
  273. }
  274. public function addEventReport(EventReport $eventReport): self
  275. {
  276. if (!$this->eventReports->contains($eventReport)) {
  277. $this->eventReports[] = $eventReport;
  278. $eventReport->setEvent($this);
  279. }
  280. return $this;
  281. }
  282. public function removeEventReport(EventReport $eventReport): self
  283. {
  284. if ($this->eventReports->removeElement($eventReport)) {
  285. // set the owning side to null (unless already changed)
  286. if ($eventReport->getEvent() === $this) {
  287. $eventReport->setEvent(null);
  288. }
  289. }
  290. return $this;
  291. }
  292. /**
  293. * @return Collection<int, File>
  294. */
  295. public function getFiles(): Collection
  296. {
  297. return $this->files;
  298. }
  299. public function addFile(File $file): self
  300. {
  301. if (!$this->files->contains($file)) {
  302. $this->files[] = $file;
  303. }
  304. return $this;
  305. }
  306. public function removeFile(File $file): self
  307. {
  308. $this->files->removeElement($file);
  309. return $this;
  310. }
  311. public function getPlaceSystem(): ?PlaceSystem
  312. {
  313. return $this->placeSystem;
  314. }
  315. public function setPlaceSystem(?PlaceSystem $placeSystem): self
  316. {
  317. $this->placeSystem = $placeSystem;
  318. return $this;
  319. }
  320. /**
  321. * @return Collection<int, AttendanceBooking>
  322. */
  323. public function getAttendanceBooking(): Collection
  324. {
  325. return $this->attendanceBooking;
  326. }
  327. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  328. {
  329. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  330. $this->attendanceBooking[] = $attendanceBooking;
  331. $attendanceBooking->setEvent($this);
  332. }
  333. return $this;
  334. }
  335. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  336. {
  337. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  338. if ($attendanceBooking->getEvent() === $this) {
  339. $attendanceBooking->setEvent(null);
  340. }
  341. }
  342. return $this;
  343. }
  344. public function getDescription(): ?string
  345. {
  346. return $this->description;
  347. }
  348. public function setDescription(?string $description): self
  349. {
  350. $this->description = $description;
  351. return $this;
  352. }
  353. public function getUrl(): ?string
  354. {
  355. return $this->url;
  356. }
  357. public function setUrl(?string $url): self
  358. {
  359. $this->url = $url;
  360. return $this;
  361. }
  362. public function getUrlTicket(): ?string
  363. {
  364. return $this->urlTicket;
  365. }
  366. public function setUrlTicket(?string $urlTicket): self
  367. {
  368. $this->urlTicket = $urlTicket;
  369. return $this;
  370. }
  371. public function getPricing(): ?PricingEventEnum
  372. {
  373. return $this->pricing;
  374. }
  375. public function setPricing(?PricingEventEnum $pricing): self
  376. {
  377. $this->pricing = $pricing;
  378. return $this;
  379. }
  380. public function getPriceMini(): ?float
  381. {
  382. return $this->priceMini;
  383. }
  384. public function setPriceMini(?float $priceMini): self
  385. {
  386. $this->priceMini = $priceMini;
  387. return $this;
  388. }
  389. public function getPriceMaxi(): ?float
  390. {
  391. return $this->priceMaxi;
  392. }
  393. public function setPriceMaxi(?float $priceMaxi): self
  394. {
  395. $this->priceMaxi = $priceMaxi;
  396. return $this;
  397. }
  398. public function getVisibility(): ?VisibilityEnum
  399. {
  400. return $this->visibility;
  401. }
  402. public function setVisibility(?VisibilityEnum $visibility): self
  403. {
  404. $this->visibility = $visibility;
  405. return $this;
  406. }
  407. }