Room.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Place;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Booking\Course;
  6. use App\Entity\Booking\EducationalProject;
  7. use App\Entity\Booking\Event;
  8. use App\Entity\Booking\Examen;
  9. use App\Entity\Person\CommissionMember;
  10. use App\Entity\Product\Equipment;
  11. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. /**
  16. * Classe ... qui ...
  17. */
  18. #[ApiResource(operations: [])]
  19. // #[Auditable]
  20. #[ORM\Entity]
  21. class Room
  22. {
  23. #[ORM\Id]
  24. #[ORM\Column]
  25. #[ORM\GeneratedValue]
  26. private ?int $id = null;
  27. #[ORM\ManyToOne(targetEntity: Place::class, inversedBy: 'rooms')]
  28. private ?Place $place = null;
  29. /** @var Collection<int, RoomControl> */
  30. #[ORM\OneToMany(targetEntity: RoomControl::class, mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
  31. #[ORM\JoinColumn(nullable: false)]
  32. private Collection $controls;
  33. /** @var Collection<int, RoomRepair> */
  34. #[ORM\OneToMany(targetEntity: RoomRepair::class, mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
  35. #[ORM\JoinColumn(nullable: false)]
  36. private Collection $repairs;
  37. /** @var Collection<int, Course> */
  38. #[ORM\OneToMany(targetEntity: Course::class, mappedBy: 'room')]
  39. private Collection $courses;
  40. /** @var Collection<int, EducationalProject> */
  41. #[ORM\OneToMany(targetEntity: EducationalProject::class, mappedBy: 'room')]
  42. private Collection $educationalProjects;
  43. /** @var Collection<int, Event> */
  44. #[ORM\OneToMany(targetEntity: Event::class, mappedBy: 'room')]
  45. private Collection $events;
  46. /** @var Collection<int, Examen> */
  47. #[ORM\OneToMany(targetEntity: Examen::class, mappedBy: 'room')]
  48. private Collection $examens;
  49. /** @var Collection<int, Equipment> */
  50. #[ORM\OneToMany(targetEntity: Equipment::class, mappedBy: 'roomStorage')]
  51. private Collection $equipmentStorages;
  52. /** @var Collection<int, Equipment> */
  53. #[ORM\OneToMany(targetEntity: Equipment::class, mappedBy: 'roomWhereIsUsed')]
  54. private Collection $equipmentUseds;
  55. public function __construct()
  56. {
  57. $this->controls = new ArrayCollection();
  58. $this->repairs = new ArrayCollection();
  59. $this->courses = new ArrayCollection();
  60. $this->educationalProjects = new ArrayCollection();
  61. $this->events = new ArrayCollection();
  62. $this->examens = new ArrayCollection();
  63. $this->equipmentStorages = new ArrayCollection();
  64. $this->equipmentUseds = new ArrayCollection();
  65. }
  66. public function getId(): ?int
  67. {
  68. return $this->id;
  69. }
  70. public function getPlace(): ?AbstractPlace
  71. {
  72. return $this->place;
  73. }
  74. public function setPlace(?AbstractPlace $place): self
  75. {
  76. $this->place = $place;
  77. return $this;
  78. }
  79. /**
  80. * @return Collection<int, RoomControl>
  81. */
  82. public function getControls(): Collection
  83. {
  84. return $this->controls;
  85. }
  86. public function addControl(RoomControl $control): self
  87. {
  88. if (!$this->controls->contains($control)) {
  89. $this->controls[] = $control;
  90. $control->setRoom($this);
  91. }
  92. return $this;
  93. }
  94. public function removeControl(RoomControl $control): self
  95. {
  96. if ($this->controls->removeElement($control)) {
  97. // set the owning side to null (unless already changed)
  98. if ($control->getRoom() === $this) {
  99. $control->setRoom(null);
  100. }
  101. }
  102. return $this;
  103. }
  104. /**
  105. * @return Collection<int, RoomRepair>
  106. */
  107. public function getRepairs(): Collection
  108. {
  109. return $this->repairs;
  110. }
  111. public function addRepair(RoomRepair $repair): self
  112. {
  113. if (!$this->repairs->contains($repair)) {
  114. $this->repairs[] = $repair;
  115. $repair->setRoom($this);
  116. }
  117. return $this;
  118. }
  119. public function removeRepair(RoomRepair $repair): self
  120. {
  121. if ($this->repairs->removeElement($repair)) {
  122. // set the owning side to null (unless already changed)
  123. if ($repair->getRoom() === $this) {
  124. $repair->setRoom(null);
  125. }
  126. }
  127. return $this;
  128. }
  129. /**
  130. * @return Collection<int, Course>
  131. */
  132. public function getCourses(): Collection
  133. {
  134. return $this->courses;
  135. }
  136. public function addCourse(Course $course): self
  137. {
  138. if (!$this->courses->contains($course)) {
  139. $this->courses[] = $course;
  140. $course->setRoom($this);
  141. }
  142. return $this;
  143. }
  144. public function removeCourse(Course $course): self
  145. {
  146. if ($this->courses->removeElement($course)) {
  147. // set the owning side to null (unless already changed)
  148. if ($course->getRoom() === $this) {
  149. $course->setRoom(null);
  150. }
  151. }
  152. return $this;
  153. }
  154. /**
  155. * @return Collection<int, EducationalProject>
  156. */
  157. public function getEducationalProjects(): Collection
  158. {
  159. return $this->educationalProjects;
  160. }
  161. public function addEducationalProject(EducationalProject $educationalProject): self
  162. {
  163. if (!$this->educationalProjects->contains($educationalProject)) {
  164. $this->educationalProjects[] = $educationalProject;
  165. $educationalProject->setRoom($this);
  166. }
  167. return $this;
  168. }
  169. public function removeEducationalProject(EducationalProject $educationalProject): self
  170. {
  171. if ($this->educationalProjects->removeElement($educationalProject)) {
  172. // set the owning side to null (unless already changed)
  173. if ($educationalProject->getRoom() === $this) {
  174. $educationalProject->setRoom(null);
  175. }
  176. }
  177. return $this;
  178. }
  179. /**
  180. * @return Collection<int, Event>
  181. */
  182. public function getEvents(): Collection
  183. {
  184. return $this->events;
  185. }
  186. public function addEvent(Event $event): self
  187. {
  188. if (!$this->events->contains($event)) {
  189. $this->events[] = $event;
  190. $event->setRoom($this);
  191. }
  192. return $this;
  193. }
  194. public function removeEvent(Event $event): self
  195. {
  196. if ($this->events->removeElement($event)) {
  197. // set the owning side to null (unless already changed)
  198. if ($event->getRoom() === $this) {
  199. $event->setRoom(null);
  200. }
  201. }
  202. return $this;
  203. }
  204. /**
  205. * @return Collection<int, Examen>
  206. */
  207. public function getExamens(): Collection
  208. {
  209. return $this->examens;
  210. }
  211. public function addExamen(Examen $examen): self
  212. {
  213. if (!$this->examens->contains($examen)) {
  214. $this->examens[] = $examen;
  215. $examen->setRoom($this);
  216. }
  217. return $this;
  218. }
  219. public function removeExamen(Examen $examen): self
  220. {
  221. if ($this->examens->removeElement($examen)) {
  222. // set the owning side to null (unless already changed)
  223. if ($examen->getRoom() === $this) {
  224. $examen->setRoom(null);
  225. }
  226. }
  227. return $this;
  228. }
  229. /**
  230. * @return Collection<int, Equipment>
  231. */
  232. public function getEquipmentStorages(): Collection
  233. {
  234. return $this->equipmentStorages;
  235. }
  236. public function addEquipmentStorage(Equipment $equipmentStorage): self
  237. {
  238. if (!$this->equipmentStorages->contains($equipmentStorage)) {
  239. $this->equipmentStorages[] = $equipmentStorage;
  240. $equipmentStorage->setRoomStorage($this);
  241. }
  242. return $this;
  243. }
  244. public function removeEquipmentStorage(Equipment $equipmentStorage): self
  245. {
  246. if ($this->equipmentStorages->removeElement($equipmentStorage)) {
  247. // set the owning side to null (unless already changed)
  248. if ($equipmentStorage->getRoomStorage() === $this) {
  249. $equipmentStorage->setRoomStorage(null);
  250. }
  251. }
  252. return $this;
  253. }
  254. /**
  255. * @return Collection<int, Equipment>
  256. */
  257. public function getEquipmentUseds(): Collection
  258. {
  259. return $this->equipmentUseds;
  260. }
  261. public function addEquipmentUsed(Equipment $equipmentUsed): self
  262. {
  263. if (!$this->equipmentUseds->contains($equipmentUsed)) {
  264. $this->equipmentUseds[] = $equipmentUsed;
  265. $equipmentUsed->setRoomWhereIsUsed($this);
  266. }
  267. return $this;
  268. }
  269. public function removeEquipmentUsed(Equipment $equipmentUsed): self
  270. {
  271. if ($this->equipmentUseds->removeElement($equipmentUsed)) {
  272. // set the owning side to null (unless already changed)
  273. if ($equipmentUsed->getRoomWhereIsUsed() === $this) {
  274. $equipmentUsed->setRoomWhereIsUsed(null);
  275. }
  276. }
  277. return $this;
  278. }
  279. }