EducationTeacher.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Education;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * Fait le lien entre un Access (professeur) et un Education (enseignement).
  12. */
  13. #[ApiResource(operations: [])]
  14. // #[Auditable]
  15. #[ORM\Entity]
  16. class EducationTeacher
  17. {
  18. #[ORM\Id]
  19. #[ORM\Column]
  20. #[ORM\GeneratedValue]
  21. private ?int $id = null;
  22. #[ORM\ManyToOne(inversedBy: 'educationTeachers')]
  23. #[ORM\JoinColumn(onDelete: 'CASCADE')]
  24. private ?Education $education = null;
  25. #[ORM\ManyToOne(inversedBy: 'educationTeachers')]
  26. private ?Access $teacher = null;
  27. /** @var Collection<int, SeizurePeriodNotation> */
  28. #[ORM\OneToMany(targetEntity: SeizurePeriodNotation::class, mappedBy: 'educationTeacher', cascade: ['persist', 'remove'], orphanRemoval: true)]
  29. private Collection $seizurePeriodNotations;
  30. public function __construct()
  31. {
  32. $this->seizurePeriodNotations = new ArrayCollection();
  33. }
  34. public function getId(): ?int
  35. {
  36. return $this->id;
  37. }
  38. public function getEducation(): ?Education
  39. {
  40. return $this->education;
  41. }
  42. public function setEducation(?Education $education): self
  43. {
  44. $this->education = $education;
  45. return $this;
  46. }
  47. public function getTeacher(): ?Access
  48. {
  49. return $this->teacher;
  50. }
  51. public function setTeacher(?Access $teacher): self
  52. {
  53. $this->teacher = $teacher;
  54. return $this;
  55. }
  56. /**
  57. * @return Collection<int, SeizurePeriodNotation>
  58. */
  59. public function getSeizurePeriodNotations(): Collection
  60. {
  61. return $this->seizurePeriodNotations;
  62. }
  63. public function addSeizurePeriodNotation(SeizurePeriodNotation $seizurePeriodNotation): self
  64. {
  65. if (!$this->seizurePeriodNotations->contains($seizurePeriodNotation)) {
  66. $this->seizurePeriodNotations[] = $seizurePeriodNotation;
  67. $seizurePeriodNotation->setEducationTeacher($this);
  68. }
  69. return $this;
  70. }
  71. public function removeSeizurePeriodNotation(SeizurePeriodNotation $seizurePeriodNotation): self
  72. {
  73. if ($this->seizurePeriodNotations->removeElement($seizurePeriodNotation)) {
  74. // set the owning side to null (unless already changed)
  75. if ($seizurePeriodNotation->getEducationTeacher() === $this) {
  76. $seizurePeriodNotation->setEducationTeacher(null);
  77. }
  78. }
  79. return $this;
  80. }
  81. }