<?php
namespace App\Entity;
use App\Repository\CourseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass=CourseRepository::class)
* @Serializer\ExclusionPolicy("ALL")
*/
class Course extends BaseEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Expose
* @Serializer\Groups({"course_participation"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose
* @Serializer\Groups({"course_participation"})
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
* @Serializer\Expose
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=CourseCategory::class, inversedBy="courses")
*/
private $category;
/**
* @ORM\OneToOne(targetEntity=FileManager::class, cascade={"persist", "remove"})
* @Serializer\Expose
*/
private $document;
/**
* @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
* @Serializer\Expose
*/
private $thumbnail;
/**
* @ORM\OneToOne(targetEntity=FileManager::class, cascade={"persist", "remove"})
* @Serializer\Expose
*/
private $video;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
*/
private $videoUrl;
/**
* @ORM\Column(type="boolean")
*/
private $isPublished = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $publishedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="courses")
*/
private $publishedBy;
/**
* @ORM\OneToMany(targetEntity=Enrollment::class, mappedBy="course", cascade={"persist", "remove"})
*/
private $enrollments;
/**
* @ORM\OneToMany(targetEntity=ModuleItem::class, mappedBy="course", cascade={"persist", "remove"})
*/
private $moduleItems;
/**
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(length=191)
*/
private $slug;
/**
* @ORM\OneToMany(targetEntity=ModuleParticipation::class, mappedBy="course", cascade={"persist", "remove"})
*/
private $moduleParticipations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
*/
private $type;
/**
* @ORM\Column(type="text", nullable=true)
* @Serializer\Expose
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity=Live::class, inversedBy="courses")
*/
private $live;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $rejectReason;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $currentPlace;
/**
* @ORM\ManyToMany(targetEntity=Module::class, inversedBy="courses")
*/
private $modules;
/**
* @ORM\OneToMany(targetEntity=CourseView::class, mappedBy="course", orphanRemoval=true)
*/
private $courseViews;
/**
* @ORM\Column(type="string", length=10000000, nullable=true)
*/
private $reviewReason;
public function __construct()
{
$this->enrollments = new ArrayCollection();
$this->moduleItems = new ArrayCollection();
$this->moduleParticipations = new ArrayCollection();
$this->modules = new ArrayCollection();
$this->courseViews = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCategory(): ?CourseCategory
{
return $this->category;
}
public function setCategory(?CourseCategory $category): self
{
$this->category = $category;
return $this;
}
public function getDocument(): ?FileManager
{
return $this->document;
}
public function setDocument(?FileManager $document): self
{
$this->document = $document;
return $this;
}
public function getThumbnail(): ?ImageManager
{
return $this->thumbnail;
}
public function setThumbnail(?ImageManager $thumbnail): self
{
$this->thumbnail = $thumbnail;
return $this;
}
public function getVideo(): ?FileManager
{
return $this->video;
}
public function setVideo(?FileManager $video): self
{
$this->video = $video;
return $this;
}
public function getVideoUrl(): ?string
{
return $this->videoUrl;
}
public function setVideoUrl(?string $videoUrl): self
{
$this->videoUrl = $videoUrl;
return $this;
}
public function isIsPublished(): ?bool
{
return $this->isPublished;
}
public function setIsPublished(bool $isPublished): self
{
$this->isPublished = $isPublished;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->publishedAt;
}
public function setPublishedAt(?\DateTimeInterface $publishedAt): self
{
$this->publishedAt = $publishedAt;
return $this;
}
public function getPublishedBy(): ?User
{
return $this->publishedBy;
}
public function setPublishedBy(?User $publishedBy): self
{
$this->publishedBy = $publishedBy;
return $this;
}
/**
* @return Collection<int, Enrollment>
*/
public function getEnrollments(): Collection
{
return $this->enrollments;
}
public function addEnrollment(Enrollment $enrollment): self
{
if (!$this->enrollments->contains($enrollment)) {
$this->enrollments[] = $enrollment;
$enrollment->setCourse($this);
}
return $this;
}
public function removeEnrollment(Enrollment $enrollment): self
{
if ($this->enrollments->removeElement($enrollment)) {
// set the owning side to null (unless already changed)
if ($enrollment->getCourse() === $this) {
$enrollment->setCourse(null);
}
}
return $this;
}
/**
* @return Collection<int, ModuleItem>
*/
public function getModuleItems(): Collection
{
return $this->moduleItems;
}
public function addModuleItem(ModuleItem $moduleItem): self
{
if (!$this->moduleItems->contains($moduleItem)) {
$this->moduleItems[] = $moduleItem;
$moduleItem->setCourse($this);
}
return $this;
}
public function removeModuleItem(ModuleItem $moduleItem): self
{
if ($this->moduleItems->removeElement($moduleItem)) {
// set the owning side to null (unless already changed)
if ($moduleItem->getCourse() === $this) {
$moduleItem->setCourse(null);
}
}
return $this;
}
/**
* Get the value of slug
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set the value of slug
*
* @return self
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, ModuleParticipation>
*/
public function getModuleParticipations(): Collection
{
return $this->moduleParticipations;
}
public function addModuleParticipation(ModuleParticipation $moduleParticipation): self
{
if (!$this->moduleParticipations->contains($moduleParticipation)) {
$this->moduleParticipations[] = $moduleParticipation;
$moduleParticipation->setCourse($this);
}
return $this;
}
public function removeModuleParticipation(ModuleParticipation $moduleParticipation): self
{
if ($this->moduleParticipations->removeElement($moduleParticipation)) {
// set the owning side to null (unless already changed)
if ($moduleParticipation->getCourse() === $this) {
$moduleParticipation->setCourse(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getLive(): ?Live
{
return $this->live;
}
public function setLive(?Live $live): self
{
$this->live = $live;
return $this;
}
public function getRejectReason(): ?string
{
return $this->rejectReason;
}
public function setRejectReason(?string $rejectReason): self
{
$this->rejectReason = $rejectReason;
return $this;
}
public function getCurrentPlace(): ?string
{
return $this->currentPlace;
}
public function setCurrentPlace(?string $currentPlace): self
{
$this->currentPlace = $currentPlace;
return $this;
}
/**
* @return Collection<int, Module>
*/
public function getModules(): Collection
{
return $this->modules;
}
public function addModule(Module $module): self
{
if (!$this->modules->contains($module)) {
$this->modules[] = $module;
}
return $this;
}
public function removeModule(Module $module): self
{
$this->modules->removeElement($module);
return $this;
}
/**
* @return Collection<int, CourseView>
*/
public function getCourseViews(): Collection
{
return $this->courseViews;
}
public function addCourseView(CourseView $courseView): self
{
if (!$this->courseViews->contains($courseView)) {
$this->courseViews[] = $courseView;
$courseView->setCourse($this);
}
return $this;
}
public function removeCourseView(CourseView $courseView): self
{
if ($this->courseViews->removeElement($courseView)) {
// set the owning side to null (unless already changed)
if ($courseView->getCourse() === $this) {
$courseView->setCourse(null);
}
}
return $this;
}
public function getReviewReason(): ?string
{
return $this->reviewReason;
}
public function setReviewReason(?string $reviewReason): self
{
$this->reviewReason = $reviewReason;
return $this;
}
}