src/Entity/GroupTicket/School.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\GroupTicket;
  3. use App\Entity\User;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity]
  9. class School extends User
  10. {
  11. #[ORM\Column(length: 255)]
  12. #[Assert\NotBlank]
  13. private string $name = '';
  14. #[ORM\OneToMany(mappedBy: 'school', targetEntity: Teacher::class, cascade: ["all"])]
  15. private Collection $teachers;
  16. #[ORM\ManyToOne(inversedBy: 'schools')]
  17. private ?TransportCompany $transportCompany = null;
  18. #[ORM\Column]
  19. #[Assert\GreaterThanOrEqual(
  20. value: 0,
  21. message: "validator.min_count"
  22. )]
  23. private ?int $maxZones = null;
  24. #[ORM\OneToMany(mappedBy: 'school', targetEntity: GroupTicketFavorite::class, cascade: ["all"])]
  25. private Collection $favorites;
  26. #[ORM\OneToOne(inversedBy: 'school', cascade: ["all"])]
  27. private ?ContactInformation $contactInformation = null;
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. $this->teachers = new ArrayCollection();
  32. $this->favorites = new ArrayCollection();
  33. }
  34. public function getName(): string
  35. {
  36. return $this->name;
  37. }
  38. public function setName(string $name): static
  39. {
  40. $this->name = $name;
  41. return $this;
  42. }
  43. /**
  44. * @return Collection<int, Teacher>
  45. */
  46. public function getTeachers(): Collection
  47. {
  48. return $this->teachers;
  49. }
  50. public function addTeacher(Teacher $teacher): static
  51. {
  52. if (!$this->teachers->contains($teacher)) {
  53. $this->teachers->add($teacher);
  54. $teacher->setSchool($this);
  55. }
  56. return $this;
  57. }
  58. public function removeTeacher(Teacher $teacher): static
  59. {
  60. if ($this->teachers->removeElement($teacher)) {
  61. // set the owning side to null (unless already changed)
  62. if ($teacher->getSchool() === $this) {
  63. $teacher->setSchool(null);
  64. }
  65. }
  66. return $this;
  67. }
  68. public function getTransportCompany(): ?TransportCompany
  69. {
  70. return $this->transportCompany;
  71. }
  72. public function setTransportCompany(?TransportCompany $transportCompany): static
  73. {
  74. $this->transportCompany = $transportCompany;
  75. return $this;
  76. }
  77. public function getMaxZones(): ?int
  78. {
  79. return $this->maxZones;
  80. }
  81. public function setMaxZones(int $maxZones): static
  82. {
  83. $this->maxZones = $maxZones;
  84. return $this;
  85. }
  86. /**
  87. * @return Collection<int, GroupTicketFavorite>
  88. */
  89. public function getFavorites(): Collection
  90. {
  91. return $this->favorites;
  92. }
  93. public function addFavorite(GroupTicketFavorite $favorite): static
  94. {
  95. if (!$this->favorites->contains($favorite)) {
  96. $this->favorites->add($favorite);
  97. $favorite->setSchool($this);
  98. }
  99. return $this;
  100. }
  101. public function removeFavorite(GroupTicketFavorite $favorite): static
  102. {
  103. if ($this->favorites->removeElement($favorite)) {
  104. // set the owning side to null (unless already changed)
  105. if ($favorite->getSchool() === $this) {
  106. $favorite->setSchool(null);
  107. }
  108. }
  109. return $this;
  110. }
  111. public function getDidokRestriktion(): string
  112. {
  113. $pc = $this->getTransportCompany()->getPublicConnections();
  114. foreach ($pc as $item){
  115. return $item->getRestriktionLabelKey();
  116. }
  117. return '';
  118. }
  119. public function getContactInformation(): ?ContactInformation
  120. {
  121. return $this->contactInformation;
  122. }
  123. public function setContactInformation(?ContactInformation $contactInformation): static
  124. {
  125. $this->contactInformation = $contactInformation;
  126. return $this;
  127. }
  128. }