src/Entity/Hospital.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HospitalRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=HospitalRepository::class)
  9. * @ORM\HasLifecycleCallbacks()
  10. */
  11. class Hospital
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="string", length=255)
  21. */
  22. private $name;
  23. /**
  24. * @ORM\Column(type="text", nullable=true)
  25. */
  26. private $description;
  27. /**
  28. * @ORM\Column(type="datetime", nullable=true)
  29. */
  30. private $updateAt;
  31. /**
  32. * @ORM\ManyToOne(targetEntity=Municipality::class, inversedBy="hospitals")
  33. * @ORM\JoinColumn(nullable=false)
  34. */
  35. private $municipality;
  36. /**
  37. * @ORM\OneToMany(targetEntity=Child::class, mappedBy="hospital")
  38. */
  39. private $children;
  40. /**
  41. * @ORM\ManyToOne(targetEntity=HospitalCategory::class, inversedBy="hospitals")
  42. */
  43. private $hospitalCategory;
  44. /**
  45. * @ORM\OneToMany(targetEntity=User::class, mappedBy="hospital")
  46. */
  47. private $users;
  48. /**
  49. * @ORM\Column(type="string", length=255, nullable=true)
  50. */
  51. private $phoneNumber;
  52. /**
  53. * @ORM\Column(type="string", length=255, nullable=true)
  54. */
  55. private $neighborhood;
  56. /**
  57. * @ORM\OneToMany(targetEntity=DeathCertificate::class, mappedBy="placeOfDeath")
  58. */
  59. private $deathCertificates;
  60. public function __construct()
  61. {
  62. $this->enfants = new ArrayCollection();
  63. $this->__updateDate();
  64. $this->children = new ArrayCollection();
  65. $this->users = new ArrayCollection();
  66. $this->deathCertificates = new ArrayCollection();
  67. }
  68. public function getId(): ?int
  69. {
  70. return $this->id;
  71. }
  72. public function getName(): ?string
  73. {
  74. return $this->name;
  75. }
  76. public function setName(string $name): self
  77. {
  78. $this->name = $name;
  79. return $this;
  80. }
  81. public function getDescription(): ?string
  82. {
  83. return $this->description;
  84. }
  85. public function setDescription(?string $description): self
  86. {
  87. $this->description = $description;
  88. return $this;
  89. }
  90. public function getUpdateAt(): ?\DateTimeInterface
  91. {
  92. return $this->updateAt;
  93. }
  94. public function setUpdateAt(?\DateTimeInterface $updateAt): self
  95. {
  96. $this->updateAt = $updateAt;
  97. return $this;
  98. }
  99. public function getMunicipality(): ?Municipality
  100. {
  101. return $this->municipality;
  102. }
  103. public function setMunicipality(?Municipality $municipality): self
  104. {
  105. $this->municipality = $municipality;
  106. return $this;
  107. }
  108. public function __toString() {
  109. return $this->getName();
  110. }
  111. /**
  112. * @ORM\PreUpdate
  113. */
  114. public function __updateDate() {
  115. $this->setUpdateAt(new \DateTime());
  116. }
  117. /**
  118. * @return Collection|Child[]
  119. */
  120. public function getChildren(): Collection
  121. {
  122. return $this->children;
  123. }
  124. public function addChild(Child $child): self
  125. {
  126. if (!$this->children->contains($child)) {
  127. $this->children[] = $child;
  128. $child->setHospital($this);
  129. }
  130. return $this;
  131. }
  132. public function removeChild(Child $child): self
  133. {
  134. if ($this->children->contains($child)) {
  135. $this->children->removeElement($child);
  136. // set the owning side to null (unless already changed)
  137. if ($child->getHospital() === $this) {
  138. $child->setHospital(null);
  139. }
  140. }
  141. return $this;
  142. }
  143. public function getHospitalCategory(): ?HospitalCategory
  144. {
  145. return $this->hospitalCategory;
  146. }
  147. public function setHospitalCategory(?HospitalCategory $hospitalCategory): self
  148. {
  149. $this->hospitalCategory = $hospitalCategory;
  150. return $this;
  151. }
  152. /**
  153. * @return Collection|User[]
  154. */
  155. public function getUsers(): Collection
  156. {
  157. return $this->users;
  158. }
  159. public function addUser(User $user): self
  160. {
  161. if (!$this->users->contains($user)) {
  162. $this->users[] = $user;
  163. $user->setHospital($this);
  164. }
  165. return $this;
  166. }
  167. public function removeUser(User $user): self
  168. {
  169. if ($this->users->removeElement($user)) {
  170. // set the owning side to null (unless already changed)
  171. if ($user->getHospital() === $this) {
  172. $user->setHospital(null);
  173. }
  174. }
  175. return $this;
  176. }
  177. public function getPhoneNumber(): ?string
  178. {
  179. return $this->phoneNumber;
  180. }
  181. public function setPhoneNumber(?string $phoneNumber): self
  182. {
  183. $this->phoneNumber = $phoneNumber;
  184. return $this;
  185. }
  186. public function getNeighborhood(): ?string
  187. {
  188. return $this->neighborhood;
  189. }
  190. public function setNeighborhood(?string $neighborhood): self
  191. {
  192. $this->neighborhood = $neighborhood;
  193. return $this;
  194. }
  195. /**
  196. * @return Collection|DeathCertificate[]
  197. */
  198. public function getDeathCertificates(): Collection
  199. {
  200. return $this->deathCertificates;
  201. }
  202. public function addDeathCertificate(DeathCertificate $deathCertificate): self
  203. {
  204. if (!$this->deathCertificates->contains($deathCertificate)) {
  205. $this->deathCertificates[] = $deathCertificate;
  206. $deathCertificate->setPlaceOfDeath($this);
  207. }
  208. return $this;
  209. }
  210. public function removeDeathCertificate(DeathCertificate $deathCertificate): self
  211. {
  212. if ($this->deathCertificates->removeElement($deathCertificate)) {
  213. // set the owning side to null (unless already changed)
  214. if ($deathCertificate->getPlaceOfDeath() === $this) {
  215. $deathCertificate->setPlaceOfDeath(null);
  216. }
  217. }
  218. return $this;
  219. }
  220. }