src/Entity/Subscription.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Student;
  4. use App\Repository\SubscriptionRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Traits\TimeStampable;
  7. use App\Entity\Traits\Amount;
  8. /**
  9. * @ORM\Entity(repositoryClass=SubscriptionRepository::class)
  10. */
  11. class Subscription
  12. {
  13. use TimeStampable;
  14. use Amount;
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\ManyToOne(targetEntity=Student::class, inversedBy="subscriptions")
  23. * @ORM\JoinColumn(nullable=false)
  24. */
  25. private $student;
  26. /**
  27. * @ORM\ManyToOne(targetEntity=ClassRoom::class, inversedBy="subscriptions")
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. private $classRoom;
  31. /**
  32. * @ORM\ManyToOne(targetEntity=SchoolYear::class, inversedBy="subscriptions")
  33. * @ORM\JoinColumn(nullable=false)
  34. */
  35. private $schoolYear;
  36. /*
  37. 0 : Echec
  38. 1p : Success Passable
  39. 1a : Success Assez-bien
  40. 1b : Success Bien
  41. 1t : Success Tres-Bien
  42. 1e : Success Excellent
  43. A : 5 points
  44. B : 4 points
  45. C : 3 points
  46. D : 2 points
  47. E : 1 point
  48. */
  49. /**
  50. * @var string
  51. *
  52. * @ORM\Column(name="officialExamResult", type="string", length=10 , options={"default" = "1p"})
  53. */
  54. private $officialExamResult;
  55. /**
  56. * @ORM\Column(type="integer", options={"default":0})
  57. */
  58. private $discount;
  59. public function __construct()
  60. {
  61. $this->updateTimestamp();
  62. $this->setOfficialExamResult("1p");
  63. $this->setDiscount(0);
  64. $this->setAmount(0);
  65. }
  66. public function getId(): ?int
  67. {
  68. return $this->id;
  69. }
  70. public function getStudent(): ?Student
  71. {
  72. return $this->student;
  73. }
  74. public function setStudent(?Student $student): self
  75. {
  76. $this->student = $student;
  77. return $this;
  78. }
  79. public function getClassRoom(): ?ClassRoom
  80. {
  81. return $this->classRoom;
  82. }
  83. public function setClassRoom(?ClassRoom $classRoom): self
  84. {
  85. $this->classRoom = $classRoom;
  86. return $this;
  87. }
  88. public function getSchoolYear(): ?SchoolYear
  89. {
  90. return $this->schoolYear;
  91. }
  92. public function setSchoolYear(?SchoolYear $schoolYear): self
  93. {
  94. $this->schoolYear = $schoolYear;
  95. return $this;
  96. }
  97. public function getOfficialExamResult(): ?string
  98. {
  99. return $this->officialExamResult;
  100. }
  101. public function getVerbalOfficialExamResult()
  102. {
  103. $result = "PASSABLE";
  104. switch ($this->officialExamResult) {
  105. case "0":
  106. $result = "ECHEC";
  107. break;
  108. case "1p":
  109. $result = "PASSABLE";
  110. break;
  111. case "1a":
  112. $result = "ASSEZ-BIEN";
  113. break;
  114. case "1b":
  115. $result = "BIEN";
  116. break;
  117. case "1t":
  118. $result = "TRES-BIEN";
  119. break;
  120. case "1e":
  121. $result = "EXCELLENT";
  122. break;
  123. case "A":
  124. $result = "5 POINTS";
  125. break;
  126. case "B":
  127. $result = "4 POINTS";
  128. break;
  129. case "C":
  130. $result = "3 POINTS";
  131. break;
  132. case "D":
  133. $result = "2 POINTS";
  134. break;
  135. case "E":
  136. $result = "1 POINTS";
  137. break;
  138. }
  139. return $result;
  140. }
  141. public function setOfficialExamResult(?string $officialExamResult): static
  142. {
  143. $this->officialExamResult = $officialExamResult;
  144. return $this;
  145. }
  146. public function getDiscount(): ?int
  147. {
  148. return $this->discount;
  149. }
  150. public function setDiscount(int $discount): static
  151. {
  152. $this->discount = $discount;
  153. return $this;
  154. }
  155. /**
  156. *
  157. * @return string
  158. */
  159. public function __toString()
  160. {
  161. $student = (is_null($this->getStudent())) ? "" : $this->getStudent();
  162. $year = (is_null($this->getSchoolYear())) ? "" : $this->getSchoolYear();
  163. return $student . " " . $year ;
  164. }
  165. }