src/Entity/GroupTicket/Teacher.php line 13

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity]
  10. class Teacher extends User
  11. {
  12. #[ORM\OneToMany(mappedBy: 'teacher', targetEntity: GroupTicket::class, cascade: ["all"])]
  13. private Collection $groupTickets;
  14. #[ORM\ManyToOne(inversedBy: 'teachers')]
  15. private ?School $school = null;
  16. #[ORM\ManyToMany(targetEntity: School::class)]
  17. #[ORM\JoinTable(name: 'group_tickets_teacher_additional_schools')]
  18. private Collection $additionalSchools;
  19. #[ORM\Column(type: Types::DATE_MUTABLE)]
  20. #[Assert\NotBlank]
  21. private ?\DateTimeInterface $birthday = null;
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. $this->groupTickets = new ArrayCollection();
  26. $this->additionalSchools = new ArrayCollection();
  27. }
  28. /**
  29. * @return Collection<int, GroupTicket>
  30. */
  31. public function getGroupTickets(): Collection
  32. {
  33. return $this->groupTickets;
  34. }
  35. public function addGroupTicket(GroupTicket $groupTicket): static
  36. {
  37. if (!$this->groupTickets->contains($groupTicket)) {
  38. $this->groupTickets->add($groupTicket);
  39. $groupTicket->setTeacher($this);
  40. }
  41. return $this;
  42. }
  43. public function removeGroupTicket(GroupTicket $groupTicket): static
  44. {
  45. if ($this->groupTickets->removeElement($groupTicket)) {
  46. // set the owning side to null (unless already changed)
  47. if ($groupTicket->getTeacher() === $this) {
  48. $groupTicket->setTeacher(null);
  49. }
  50. }
  51. return $this;
  52. }
  53. public function getSchool(): ?School
  54. {
  55. return $this->school;
  56. }
  57. public function setSchool(?School $school): static
  58. {
  59. $this->school = $school;
  60. return $this;
  61. }
  62. /**
  63. * @return Collection<int, School>
  64. */
  65. public function getAdditionalSchools(): Collection
  66. {
  67. return $this->additionalSchools;
  68. }
  69. public function addAdditionalSchool(School $school): static
  70. {
  71. if (!$this->additionalSchools->contains($school)) {
  72. $this->additionalSchools->add($school);
  73. }
  74. return $this;
  75. }
  76. public function removeAdditionalSchool(School $school): static
  77. {
  78. $this->additionalSchools->removeElement($school);
  79. return $this;
  80. }
  81. public function getBirthday(): ?\DateTimeInterface
  82. {
  83. return $this->birthday;
  84. }
  85. public function setBirthday(?\DateTimeInterface $birthday): static
  86. {
  87. $this->birthday = $birthday;
  88. return $this;
  89. }
  90. public function getDidokRestriktion(): string
  91. {
  92. $pc = $this->getSchool()->getTransportCompany()->getPublicConnections();
  93. foreach ($pc as $item){
  94. return $item->getRestriktionLabelKey();
  95. }
  96. return '';
  97. }
  98. }