Event.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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. #[ORM\Column(length: 255, nullable: true)]
  100. private ?string $helloAssoSlug = null;
  101. #[ORM\Column(length: 255, nullable: true)]
  102. private ?string $helloAssoPublicUrl = null;
  103. public function __construct()
  104. {
  105. $this->eventRecur = new ArrayCollection();
  106. $this->timeline = new ArrayCollection();
  107. $this->eventUser = new ArrayCollection();
  108. $this->categories = new ArrayCollection();
  109. $this->eventReports = new ArrayCollection();
  110. $this->files = new ArrayCollection();
  111. $this->attendanceBooking = new ArrayCollection();
  112. $this->organizer = new ArrayCollection();
  113. $this->equipments = new ArrayCollection();
  114. parent::__construct();
  115. }
  116. public function getOrganization(): ?Organization
  117. {
  118. return $this->organization;
  119. }
  120. public function setOrganization(?Organization $organization): self
  121. {
  122. $this->organization = $organization;
  123. return $this;
  124. }
  125. public function getPlace(): ?Place
  126. {
  127. return $this->place;
  128. }
  129. public function setPlace(?Place $place): self
  130. {
  131. $this->place = $place;
  132. return $this;
  133. }
  134. public function getRoom(): ?Room
  135. {
  136. return $this->room;
  137. }
  138. public function setRoom(?Room $room): self
  139. {
  140. $this->room = $room;
  141. return $this;
  142. }
  143. /**
  144. * @return Collection<int, EventRecur>
  145. */
  146. public function getEventRecur(): Collection
  147. {
  148. return $this->eventRecur;
  149. }
  150. public function addEventRecur(EventRecur $eventRecur): self
  151. {
  152. if (!$this->eventRecur->contains($eventRecur)) {
  153. $this->eventRecur[] = $eventRecur;
  154. $eventRecur->setEvent($this);
  155. }
  156. return $this;
  157. }
  158. public function removeEventRecur(EventRecur $eventRecur): self
  159. {
  160. if ($this->eventRecur->removeElement($eventRecur)) {
  161. // set the owning side to null (unless already changed)
  162. if ($eventRecur->getEvent() === $this) {
  163. $eventRecur->setEvent(null);
  164. }
  165. }
  166. return $this;
  167. }
  168. /**
  169. * @return Collection<int, Event>
  170. */
  171. public function getTimeline(): Collection
  172. {
  173. return $this->timeline;
  174. }
  175. public function addTimeline(Event $timeline): self
  176. {
  177. if (!$this->timeline->contains($timeline)) {
  178. $this->timeline[] = $timeline;
  179. $timeline->setParent($this);
  180. }
  181. return $this;
  182. }
  183. public function removeTimeline(Event $timeline): self
  184. {
  185. if ($this->timeline->removeElement($timeline)) {
  186. // set the owning side to null (unless already changed)
  187. if ($timeline->getParent() === $this) {
  188. $timeline->setParent(null);
  189. }
  190. }
  191. return $this;
  192. }
  193. public function getParent(): ?self
  194. {
  195. return $this->parent;
  196. }
  197. public function setParent(?self $parent): self
  198. {
  199. $this->parent = $parent;
  200. return $this;
  201. }
  202. public function getImage(): ?File
  203. {
  204. return $this->image;
  205. }
  206. public function setImage(?File $image): self
  207. {
  208. $this->image = $image;
  209. return $this;
  210. }
  211. public function getGender(): ?EventGender
  212. {
  213. return $this->gender;
  214. }
  215. public function setGender(?EventGender $gender): self
  216. {
  217. $this->gender = $gender;
  218. return $this;
  219. }
  220. /**
  221. * @return Collection<int, EventUser>
  222. */
  223. public function getEventUser(): Collection
  224. {
  225. return $this->eventUser;
  226. }
  227. public function addEventUser(EventUser $eventUser): self
  228. {
  229. if (!$this->eventUser->contains($eventUser)) {
  230. $this->eventUser[] = $eventUser;
  231. $eventUser->setEvent($this);
  232. }
  233. return $this;
  234. }
  235. public function removeEventUser(EventUser $eventUser): self
  236. {
  237. if ($this->eventUser->removeElement($eventUser)) {
  238. // set the owning side to null (unless already changed)
  239. if ($eventUser->getEvent() === $this) {
  240. $eventUser->setEvent(null);
  241. }
  242. }
  243. return $this;
  244. }
  245. /**
  246. * @return Collection<int, Categories>
  247. */
  248. public function getCategories(): Collection
  249. {
  250. return $this->categories;
  251. }
  252. public function addCategory(Categories $category): self
  253. {
  254. if (!$this->categories->contains($category)) {
  255. $this->categories[] = $category;
  256. }
  257. return $this;
  258. }
  259. public function removeCategory(Categories $category): self
  260. {
  261. $this->categories->removeElement($category);
  262. return $this;
  263. }
  264. public function removeAllCategories(): self
  265. {
  266. foreach ($this->categories as $category) {
  267. $this->removeCategory($category);
  268. }
  269. return $this;
  270. }
  271. /**
  272. * @return Collection<int, EventReport>
  273. */
  274. public function getEventReports(): Collection
  275. {
  276. return $this->eventReports;
  277. }
  278. public function addEventReport(EventReport $eventReport): self
  279. {
  280. if (!$this->eventReports->contains($eventReport)) {
  281. $this->eventReports[] = $eventReport;
  282. $eventReport->setEvent($this);
  283. }
  284. return $this;
  285. }
  286. public function removeEventReport(EventReport $eventReport): self
  287. {
  288. if ($this->eventReports->removeElement($eventReport)) {
  289. // set the owning side to null (unless already changed)
  290. if ($eventReport->getEvent() === $this) {
  291. $eventReport->setEvent(null);
  292. }
  293. }
  294. return $this;
  295. }
  296. /**
  297. * @return Collection<int, File>
  298. */
  299. public function getFiles(): Collection
  300. {
  301. return $this->files;
  302. }
  303. public function addFile(File $file): self
  304. {
  305. if (!$this->files->contains($file)) {
  306. $this->files[] = $file;
  307. }
  308. return $this;
  309. }
  310. public function removeFile(File $file): self
  311. {
  312. $this->files->removeElement($file);
  313. return $this;
  314. }
  315. public function getPlaceSystem(): ?PlaceSystem
  316. {
  317. return $this->placeSystem;
  318. }
  319. public function setPlaceSystem(?PlaceSystem $placeSystem): self
  320. {
  321. $this->placeSystem = $placeSystem;
  322. return $this;
  323. }
  324. /**
  325. * @return Collection<int, AttendanceBooking>
  326. */
  327. public function getAttendanceBooking(): Collection
  328. {
  329. return $this->attendanceBooking;
  330. }
  331. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  332. {
  333. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  334. $this->attendanceBooking[] = $attendanceBooking;
  335. $attendanceBooking->setEvent($this);
  336. }
  337. return $this;
  338. }
  339. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  340. {
  341. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  342. if ($attendanceBooking->getEvent() === $this) {
  343. $attendanceBooking->setEvent(null);
  344. }
  345. }
  346. return $this;
  347. }
  348. public function getDescription(): ?string
  349. {
  350. return $this->description;
  351. }
  352. public function setDescription(?string $description): self
  353. {
  354. $this->description = $description;
  355. return $this;
  356. }
  357. public function getUrl(): ?string
  358. {
  359. return $this->url;
  360. }
  361. public function setUrl(?string $url): self
  362. {
  363. $this->url = $url;
  364. return $this;
  365. }
  366. public function getUrlTicket(): ?string
  367. {
  368. return $this->urlTicket;
  369. }
  370. public function setUrlTicket(?string $urlTicket): self
  371. {
  372. $this->urlTicket = $urlTicket;
  373. return $this;
  374. }
  375. public function getPricing(): ?PricingEventEnum
  376. {
  377. return $this->pricing;
  378. }
  379. public function setPricing(?PricingEventEnum $pricing): self
  380. {
  381. $this->pricing = $pricing;
  382. return $this;
  383. }
  384. public function getPriceMini(): ?float
  385. {
  386. return $this->priceMini;
  387. }
  388. public function setPriceMini(?float $priceMini): self
  389. {
  390. $this->priceMini = $priceMini;
  391. return $this;
  392. }
  393. public function getPriceMaxi(): ?float
  394. {
  395. return $this->priceMaxi;
  396. }
  397. public function setPriceMaxi(?float $priceMaxi): self
  398. {
  399. $this->priceMaxi = $priceMaxi;
  400. return $this;
  401. }
  402. public function getVisibility(): ?VisibilityEnum
  403. {
  404. return $this->visibility;
  405. }
  406. public function setVisibility(?VisibilityEnum $visibility): self
  407. {
  408. $this->visibility = $visibility;
  409. return $this;
  410. }
  411. public function getHelloAssoSlug(): ?string
  412. {
  413. return $this->helloAssoSlug;
  414. }
  415. public function setHelloAssoSlug(?string $helloAssoSlug): self
  416. {
  417. $this->helloAssoSlug = $helloAssoSlug;
  418. return $this;
  419. }
  420. public function getHelloAssoPublicUrl(): ?string
  421. {
  422. return $this->helloAssoPublicUrl;
  423. }
  424. public function setHelloAssoPublicUrl(?string $helloAssoPublicUrl): self
  425. {
  426. $this->helloAssoPublicUrl = $helloAssoPublicUrl;
  427. return $this;
  428. }
  429. }