src/Entity/Core/Textbook/TextbookSession.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core\Textbook;
  3. use App\Entity\Core\Classroom\Classroom;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JsonSerializable;
  8. #[ORM\Table('textbook_session')]
  9. #[ORM\Entity(repositoryClass: TextbookSessionRepository::class)]
  10. class TextbookSession implements JsonSerializable
  11. {
  12. /**
  13. * @var int
  14. */
  15. #[ORM\Column(name: 'id', type: 'integer')]
  16. #[ORM\Id]
  17. #[ORM\GeneratedValue(strategy: 'AUTO')]
  18. private $id;
  19. /**
  20. * @var Classroom
  21. */
  22. #[ORM\JoinColumn(name: 'classroom', referencedColumnName: 'id', onDelete: 'CASCADE')]
  23. #[ORM\ManyToOne(targetEntity: Classroom::class, inversedBy: 'sessions')]
  24. private $classroom;
  25. /**
  26. * @var ArrayCollection|TextbookSubTopic[]
  27. */
  28. #[ORM\JoinTable(name: 'textbook_session_subtopic')]
  29. #[ORM\JoinColumn(name: 'textbook_session', referencedColumnName: 'id')]
  30. #[ORM\InverseJoinColumn(name: 'subtopic', referencedColumnName: 'id')]
  31. #[ORM\ManyToMany(targetEntity: TextbookSubTopic::class, inversedBy: 'textbookSessions')]
  32. private $textbookSubtopics;
  33. /**
  34. * @var DateTime
  35. */
  36. #[ORM\Column(name: 'start_time', type: 'datetime', nullable: true)]
  37. private $startTime;
  38. #[ORM\Column(name: 'deadline', type: 'datetime')]
  39. private $deadline;
  40. #[ORM\Column(type: 'string', nullable: true)]
  41. private $name;
  42. #[ORM\Column(type: 'text', nullable: true)]
  43. private $notice;
  44. /**
  45. * @var TextbookSessionUnit[]
  46. */
  47. #[ORM\OneToMany(targetEntity: TextbookSessionUnit::class, mappedBy: 'session', cascade: ['persist'])]
  48. private $units;
  49. /**
  50. * @var integer
  51. */
  52. #[ORM\Column(type: 'integer', nullable: false, options: ['default' => 1])]
  53. private $isEnabled = 1;
  54. /**
  55. * @return Classroom
  56. */
  57. public function getClassroom()
  58. {
  59. return $this->classroom;
  60. }
  61. /**
  62. * @param Classroom $classroom
  63. */
  64. public function setClassroom($classroom)
  65. {
  66. $this->classroom = $classroom;
  67. }
  68. /**
  69. * @return DateTime
  70. */
  71. public function getStartTime()
  72. {
  73. return $this->startTime;
  74. }
  75. /**
  76. * @param DateTime $startTime
  77. */
  78. public function setStartTime($startTime)
  79. {
  80. $this->startTime = $startTime;
  81. }
  82. /**
  83. * @return DateTime
  84. */
  85. public function getDeadline()
  86. {
  87. return $this->deadline;
  88. }
  89. /**
  90. * @param DateTime $deadline
  91. */
  92. public function setDeadline($deadline)
  93. {
  94. $this->deadline = $deadline;
  95. }
  96. /**
  97. * @return mixed
  98. */
  99. public function getName()
  100. {
  101. return $this->name;
  102. }
  103. /**
  104. * @param mixed $name
  105. */
  106. public function setName($name)
  107. {
  108. $this->name = $name;
  109. }
  110. /**
  111. * @return int
  112. */
  113. public function getId()
  114. {
  115. return $this->id;
  116. }
  117. /**
  118. *
  119. */
  120. public function resetId()
  121. {
  122. $this->id = null;
  123. }
  124. /**
  125. * @return TextbookSubTopic[]|ArrayCollection
  126. */
  127. public function getTextbookSubtopics()
  128. {
  129. return $this->textbookSubtopics;
  130. }
  131. /**
  132. * @param TextbookSubTopic[]|ArrayCollection $textbookSubtopics
  133. */
  134. public function setTextbookSubtopics($textbookSubtopics)
  135. {
  136. $this->textbookSubtopics = $textbookSubtopics;
  137. }
  138. /**
  139. * @return TextbookSessionUnit[]
  140. */
  141. public function getUnits()
  142. {
  143. return $this->units;
  144. }
  145. /**
  146. * @param TextbookSessionUnit[] $units
  147. */
  148. public function setUnits($units)
  149. {
  150. $this->units = $units;
  151. }
  152. public function getNotice(): ?string
  153. {
  154. return $this->notice;
  155. }
  156. public function setNotice(?String $notice)
  157. {
  158. $this->notice = $notice;
  159. }
  160. public function getisEnabled(): int
  161. {
  162. return $this->isEnabled;
  163. }
  164. public function setIsEnabled(int $isEnabled): void
  165. {
  166. $this->isEnabled = $isEnabled;
  167. }
  168. public function jsonSerialize(): mixed
  169. {
  170. return [
  171. "id" => $this->getId(),
  172. "name" => $this->getName(),
  173. "startTime" => $this->getStartTime(),
  174. "deadline" => $this->getDeadline(),
  175. ];
  176. }
  177. }