src/Entity/Enrollment.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EnrollmentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=EnrollmentRepository::class)
  9. */
  10. class Enrollment
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="enrollments")
  20. * @ORM\JoinColumn(nullable=false)
  21. */
  22. private $user;
  23. /**
  24. * @ORM\ManyToOne(targetEntity=Course::class, inversedBy="enrollments")
  25. * @ORM\JoinColumn(nullable=false)
  26. */
  27. private $course;
  28. /**
  29. * @ORM\Column(type="datetime")
  30. */
  31. private $enrollmentDate;
  32. /**
  33. * @ORM\OneToMany(targetEntity=LearningProgress::class, mappedBy="enrollment")
  34. */
  35. private $learningProgress;
  36. public function __construct()
  37. {
  38. $this->learningProgress = new ArrayCollection();
  39. }
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getUser(): ?User
  45. {
  46. return $this->user;
  47. }
  48. public function setUser(?User $user): self
  49. {
  50. $this->user = $user;
  51. return $this;
  52. }
  53. public function getCourse(): ?Course
  54. {
  55. return $this->course;
  56. }
  57. public function setCourse(?Course $course): self
  58. {
  59. $this->course = $course;
  60. return $this;
  61. }
  62. public function getEnrollmentDate(): ?\DateTimeInterface
  63. {
  64. return $this->enrollmentDate;
  65. }
  66. public function setEnrollmentDate(\DateTimeInterface $enrollmentDate): self
  67. {
  68. $this->enrollmentDate = $enrollmentDate;
  69. return $this;
  70. }
  71. /**
  72. * @return Collection<int, LearningProgress>
  73. */
  74. public function getLearningProgress(): Collection
  75. {
  76. return $this->learningProgress;
  77. }
  78. public function addLearningProgress(LearningProgress $learningProgress): self
  79. {
  80. if (!$this->learningProgress->contains($learningProgress)) {
  81. $this->learningProgress[] = $learningProgress;
  82. $learningProgress->setEnrollment($this);
  83. }
  84. return $this;
  85. }
  86. public function removeLearningProgress(LearningProgress $learningProgress): self
  87. {
  88. if ($this->learningProgress->removeElement($learningProgress)) {
  89. // set the owning side to null (unless already changed)
  90. if ($learningProgress->getEnrollment() === $this) {
  91. $learningProgress->setEnrollment(null);
  92. }
  93. }
  94. return $this;
  95. }
  96. }