src/Entity/Course.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CourseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use JMS\Serializer\Annotation as Serializer;
  9. /**
  10. * @ORM\Entity(repositoryClass=CourseRepository::class)
  11. * @Serializer\ExclusionPolicy("ALL")
  12. */
  13. class Course extends BaseEntity
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. * @Serializer\Expose
  20. * @Serializer\Groups({"course_participation"})
  21. */
  22. private $id;
  23. /**
  24. * @ORM\Column(type="string", length=255)
  25. * @Serializer\Expose
  26. * @Serializer\Groups({"course_participation"})
  27. */
  28. private $title;
  29. /**
  30. * @ORM\Column(type="text", nullable=true)
  31. * @Serializer\Expose
  32. */
  33. private $description;
  34. /**
  35. * @ORM\ManyToOne(targetEntity=CourseCategory::class, inversedBy="courses")
  36. */
  37. private $category;
  38. /**
  39. * @ORM\OneToOne(targetEntity=FileManager::class, cascade={"persist", "remove"})
  40. * @Serializer\Expose
  41. */
  42. private $document;
  43. /**
  44. * @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
  45. * @Serializer\Expose
  46. */
  47. private $thumbnail;
  48. /**
  49. * @ORM\OneToOne(targetEntity=FileManager::class, cascade={"persist", "remove"})
  50. * @Serializer\Expose
  51. */
  52. private $video;
  53. /**
  54. * @ORM\Column(type="string", length=255, nullable=true)
  55. * @Serializer\Expose
  56. */
  57. private $videoUrl;
  58. /**
  59. * @ORM\Column(type="boolean")
  60. */
  61. private $isPublished = false;
  62. /**
  63. * @ORM\Column(type="datetime", nullable=true)
  64. */
  65. private $publishedAt;
  66. /**
  67. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="courses")
  68. */
  69. private $publishedBy;
  70. /**
  71. * @ORM\OneToMany(targetEntity=Enrollment::class, mappedBy="course", cascade={"persist", "remove"})
  72. */
  73. private $enrollments;
  74. /**
  75. * @ORM\OneToMany(targetEntity=ModuleItem::class, mappedBy="course", cascade={"persist", "remove"})
  76. */
  77. private $moduleItems;
  78. /**
  79. * @Gedmo\Slug(fields={"title"})
  80. * @ORM\Column(length=191)
  81. */
  82. private $slug;
  83. /**
  84. * @ORM\OneToMany(targetEntity=ModuleParticipation::class, mappedBy="course", cascade={"persist", "remove"})
  85. */
  86. private $moduleParticipations;
  87. /**
  88. * @ORM\Column(type="string", length=255, nullable=true)
  89. * @Serializer\Expose
  90. */
  91. private $type;
  92. /**
  93. * @ORM\Column(type="text", nullable=true)
  94. * @Serializer\Expose
  95. */
  96. private $content;
  97. /**
  98. * @ORM\ManyToOne(targetEntity=Live::class, inversedBy="courses")
  99. */
  100. private $live;
  101. /**
  102. * @ORM\Column(type="text", nullable=true)
  103. */
  104. private $rejectReason;
  105. /**
  106. * @ORM\Column(type="string", length=255, nullable=true)
  107. */
  108. private $currentPlace;
  109. /**
  110. * @ORM\ManyToMany(targetEntity=Module::class, inversedBy="courses")
  111. */
  112. private $modules;
  113. /**
  114. * @ORM\OneToMany(targetEntity=CourseView::class, mappedBy="course", orphanRemoval=true)
  115. */
  116. private $courseViews;
  117. /**
  118. * @ORM\Column(type="string", length=10000000, nullable=true)
  119. */
  120. private $reviewReason;
  121. public function __construct()
  122. {
  123. $this->enrollments = new ArrayCollection();
  124. $this->moduleItems = new ArrayCollection();
  125. $this->moduleParticipations = new ArrayCollection();
  126. $this->modules = new ArrayCollection();
  127. $this->courseViews = new ArrayCollection();
  128. }
  129. public function getId(): ?int
  130. {
  131. return $this->id;
  132. }
  133. public function getTitle(): ?string
  134. {
  135. return $this->title;
  136. }
  137. public function setTitle(string $title): self
  138. {
  139. $this->title = $title;
  140. return $this;
  141. }
  142. public function getDescription(): ?string
  143. {
  144. return $this->description;
  145. }
  146. public function setDescription(?string $description): self
  147. {
  148. $this->description = $description;
  149. return $this;
  150. }
  151. public function getCategory(): ?CourseCategory
  152. {
  153. return $this->category;
  154. }
  155. public function setCategory(?CourseCategory $category): self
  156. {
  157. $this->category = $category;
  158. return $this;
  159. }
  160. public function getDocument(): ?FileManager
  161. {
  162. return $this->document;
  163. }
  164. public function setDocument(?FileManager $document): self
  165. {
  166. $this->document = $document;
  167. return $this;
  168. }
  169. public function getThumbnail(): ?ImageManager
  170. {
  171. return $this->thumbnail;
  172. }
  173. public function setThumbnail(?ImageManager $thumbnail): self
  174. {
  175. $this->thumbnail = $thumbnail;
  176. return $this;
  177. }
  178. public function getVideo(): ?FileManager
  179. {
  180. return $this->video;
  181. }
  182. public function setVideo(?FileManager $video): self
  183. {
  184. $this->video = $video;
  185. return $this;
  186. }
  187. public function getVideoUrl(): ?string
  188. {
  189. return $this->videoUrl;
  190. }
  191. public function setVideoUrl(?string $videoUrl): self
  192. {
  193. $this->videoUrl = $videoUrl;
  194. return $this;
  195. }
  196. public function isIsPublished(): ?bool
  197. {
  198. return $this->isPublished;
  199. }
  200. public function setIsPublished(bool $isPublished): self
  201. {
  202. $this->isPublished = $isPublished;
  203. return $this;
  204. }
  205. public function getPublishedAt(): ?\DateTimeInterface
  206. {
  207. return $this->publishedAt;
  208. }
  209. public function setPublishedAt(?\DateTimeInterface $publishedAt): self
  210. {
  211. $this->publishedAt = $publishedAt;
  212. return $this;
  213. }
  214. public function getPublishedBy(): ?User
  215. {
  216. return $this->publishedBy;
  217. }
  218. public function setPublishedBy(?User $publishedBy): self
  219. {
  220. $this->publishedBy = $publishedBy;
  221. return $this;
  222. }
  223. /**
  224. * @return Collection<int, Enrollment>
  225. */
  226. public function getEnrollments(): Collection
  227. {
  228. return $this->enrollments;
  229. }
  230. public function addEnrollment(Enrollment $enrollment): self
  231. {
  232. if (!$this->enrollments->contains($enrollment)) {
  233. $this->enrollments[] = $enrollment;
  234. $enrollment->setCourse($this);
  235. }
  236. return $this;
  237. }
  238. public function removeEnrollment(Enrollment $enrollment): self
  239. {
  240. if ($this->enrollments->removeElement($enrollment)) {
  241. // set the owning side to null (unless already changed)
  242. if ($enrollment->getCourse() === $this) {
  243. $enrollment->setCourse(null);
  244. }
  245. }
  246. return $this;
  247. }
  248. /**
  249. * @return Collection<int, ModuleItem>
  250. */
  251. public function getModuleItems(): Collection
  252. {
  253. return $this->moduleItems;
  254. }
  255. public function addModuleItem(ModuleItem $moduleItem): self
  256. {
  257. if (!$this->moduleItems->contains($moduleItem)) {
  258. $this->moduleItems[] = $moduleItem;
  259. $moduleItem->setCourse($this);
  260. }
  261. return $this;
  262. }
  263. public function removeModuleItem(ModuleItem $moduleItem): self
  264. {
  265. if ($this->moduleItems->removeElement($moduleItem)) {
  266. // set the owning side to null (unless already changed)
  267. if ($moduleItem->getCourse() === $this) {
  268. $moduleItem->setCourse(null);
  269. }
  270. }
  271. return $this;
  272. }
  273. /**
  274. * Get the value of slug
  275. */
  276. public function getSlug()
  277. {
  278. return $this->slug;
  279. }
  280. /**
  281. * Set the value of slug
  282. *
  283. * @return self
  284. */
  285. public function setSlug($slug)
  286. {
  287. $this->slug = $slug;
  288. return $this;
  289. }
  290. /**
  291. * @return Collection<int, ModuleParticipation>
  292. */
  293. public function getModuleParticipations(): Collection
  294. {
  295. return $this->moduleParticipations;
  296. }
  297. public function addModuleParticipation(ModuleParticipation $moduleParticipation): self
  298. {
  299. if (!$this->moduleParticipations->contains($moduleParticipation)) {
  300. $this->moduleParticipations[] = $moduleParticipation;
  301. $moduleParticipation->setCourse($this);
  302. }
  303. return $this;
  304. }
  305. public function removeModuleParticipation(ModuleParticipation $moduleParticipation): self
  306. {
  307. if ($this->moduleParticipations->removeElement($moduleParticipation)) {
  308. // set the owning side to null (unless already changed)
  309. if ($moduleParticipation->getCourse() === $this) {
  310. $moduleParticipation->setCourse(null);
  311. }
  312. }
  313. return $this;
  314. }
  315. public function getType(): ?string
  316. {
  317. return $this->type;
  318. }
  319. public function setType(?string $type): self
  320. {
  321. $this->type = $type;
  322. return $this;
  323. }
  324. public function getContent(): ?string
  325. {
  326. return $this->content;
  327. }
  328. public function setContent(?string $content): self
  329. {
  330. $this->content = $content;
  331. return $this;
  332. }
  333. public function getLive(): ?Live
  334. {
  335. return $this->live;
  336. }
  337. public function setLive(?Live $live): self
  338. {
  339. $this->live = $live;
  340. return $this;
  341. }
  342. public function getRejectReason(): ?string
  343. {
  344. return $this->rejectReason;
  345. }
  346. public function setRejectReason(?string $rejectReason): self
  347. {
  348. $this->rejectReason = $rejectReason;
  349. return $this;
  350. }
  351. public function getCurrentPlace(): ?string
  352. {
  353. return $this->currentPlace;
  354. }
  355. public function setCurrentPlace(?string $currentPlace): self
  356. {
  357. $this->currentPlace = $currentPlace;
  358. return $this;
  359. }
  360. /**
  361. * @return Collection<int, Module>
  362. */
  363. public function getModules(): Collection
  364. {
  365. return $this->modules;
  366. }
  367. public function addModule(Module $module): self
  368. {
  369. if (!$this->modules->contains($module)) {
  370. $this->modules[] = $module;
  371. }
  372. return $this;
  373. }
  374. public function removeModule(Module $module): self
  375. {
  376. $this->modules->removeElement($module);
  377. return $this;
  378. }
  379. /**
  380. * @return Collection<int, CourseView>
  381. */
  382. public function getCourseViews(): Collection
  383. {
  384. return $this->courseViews;
  385. }
  386. public function addCourseView(CourseView $courseView): self
  387. {
  388. if (!$this->courseViews->contains($courseView)) {
  389. $this->courseViews[] = $courseView;
  390. $courseView->setCourse($this);
  391. }
  392. return $this;
  393. }
  394. public function removeCourseView(CourseView $courseView): self
  395. {
  396. if ($this->courseViews->removeElement($courseView)) {
  397. // set the owning side to null (unless already changed)
  398. if ($courseView->getCourse() === $this) {
  399. $courseView->setCourse(null);
  400. }
  401. }
  402. return $this;
  403. }
  404. public function getReviewReason(): ?string
  405. {
  406. return $this->reviewReason;
  407. }
  408. public function setReviewReason(?string $reviewReason): self
  409. {
  410. $this->reviewReason = $reviewReason;
  411. return $this;
  412. }
  413. }