src/Entity/HospitalCategory.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HospitalCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=HospitalCategoryRepository::class)
  9. */
  10. class HospitalCategory
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(type="string", length=255)
  20. */
  21. private $wording;
  22. /**
  23. * @ORM\Column(type="string", length=255, nullable=true)
  24. */
  25. private $description;
  26. /**
  27. * @ORM\Column(type="datetime")
  28. */
  29. private $updateAt;
  30. /**
  31. * @ORM\OneToMany(targetEntity=Hospital::class, mappedBy="hospitalCategory")
  32. */
  33. private $hospitals;
  34. public function __construct()
  35. {
  36. $this->hospitals = new ArrayCollection();
  37. $this->__updateDate();
  38. }
  39. public function getId(): ?int
  40. {
  41. return $this->id;
  42. }
  43. public function getWording(): ?string
  44. {
  45. return $this->wording;
  46. }
  47. public function setWording(string $wording): self
  48. {
  49. $this->wording = $wording;
  50. return $this;
  51. }
  52. public function getDescription(): ?string
  53. {
  54. return $this->description;
  55. }
  56. public function setDescription(?string $description): self
  57. {
  58. $this->description = $description;
  59. return $this;
  60. }
  61. public function getUpdateAt(): ?\DateTimeInterface
  62. {
  63. return $this->updateAt;
  64. }
  65. public function setUpdateAt(\DateTimeInterface $updateAt): self
  66. {
  67. $this->updateAt = $updateAt;
  68. return $this;
  69. }
  70. /**
  71. * @return Collection|Hospital[]
  72. */
  73. public function getHospitals(): Collection
  74. {
  75. return $this->hospitals;
  76. }
  77. public function addHospital(Hospital $hospital): self
  78. {
  79. if (!$this->hospitals->contains($hospital)) {
  80. $this->hospitals[] = $hospital;
  81. $hospital->setHospitalCategory($this);
  82. }
  83. return $this;
  84. }
  85. public function removeHospital(Hospital $hospital): self
  86. {
  87. if ($this->hospitals->removeElement($hospital)) {
  88. // set the owning side to null (unless already changed)
  89. if ($hospital->getHospitalCategory() === $this) {
  90. $hospital->setHospitalCategory(null);
  91. }
  92. }
  93. return $this;
  94. }
  95. public function __toString() {
  96. return $this->getWording();
  97. }
  98. /**
  99. * @ORM\PreUpdate
  100. */
  101. public function __updateDate() {
  102. $this->setUpdateAt(new \DateTime());
  103. }
  104. }