<?php
namespace App\Entity\Gos\Uniqskills;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\LessonRepository")
* @ORM\HasLifecycleCallbacks
* @Vich\Uploadable
*/
class Lesson
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isActive;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(type="string", length=191, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $reminderNewLesson;
/**
* @ORM\Column(type="integer")
*/
private $itemOrder;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $shareDate;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $shareDays;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity="LessonType", fetch="EAGER")
* @ORM\JoinColumn(name="lesson_type_id", referencedColumnName="id")
*/
private $lessonType;
/**
* @ORM\OneToMany(targetEntity="LessonReminder", mappedBy="lesson")
*/
private $lessonReminder;
/**
* @ORM\OneToMany(targetEntity="UserLesson", mappedBy="lesson")
*/
private $userLesson;
/**
* @ORM\ManyToMany(targetEntity="Package", mappedBy="lessons")
* @ORM\JoinColumn()
*/
private $package;
/**
* @ORM\ManyToOne(targetEntity="Module", inversedBy="lesson")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $module;
/**
* @ORM\ManyToOne(targetEntity="Author", inversedBy="lesson")
* @ORM\JoinColumn()
*/
private $author;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string
*/
private $advertisementPhoto;
/**
* @Vich\UploadableField(mapping="advertisement_image", fileNameProperty="advertisementPhoto")
* @var File
*/
private $advertisementPhotoFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $advertisementVideoLink;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $videoId;
/**
* @ORM\OneToMany(targetEntity=UserVideoNotes::class, mappedBy="lesson")
*/
private $userVideoNotes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $linkToAdvertisementPhoto;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $linkToAdvertisementVideo;
/**
* GOS-1860
* After how many days from the order should lesson be visible in customer panel
* default: 0 - visible immediately
* @ORM\Column(type="integer", options={"default": 0})
* @Assert\GreaterThanOrEqual(value=0)
*/
private $visibleAfterDays = 0;
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->name;
}
public function __clone()
{
$this->id = null;
$this->updatedAt = null;
}
/**
* Constructor
*/
public function __construct()
{
$this->userLesson = new \Doctrine\Common\Collections\ArrayCollection();
$this->package = new \Doctrine\Common\Collections\ArrayCollection();
$this->lessonReminder = new ArrayCollection();
$this->userVideoNotes = new ArrayCollection();
}
/**
* Add userLesson
*
* @param \App\Entity\Gos\Uniqskills\UserLesson $userLesson
* @return Lesson
*/
public function addUserLesson(\App\Entity\Gos\Uniqskills\UserLesson $userLesson)
{
$this->userLesson[] = $userLesson;
return $this;
}
/**
* Remove userLesson
*
* @param \App\Entity\Gos\Uniqskills\UserLesson $userLesson
*/
public function removeUserLesson(\App\Entity\Gos\Uniqskills\UserLesson $userLesson)
{
$this->userLesson->removeElement($userLesson);
}
/**
* Get userLesson
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getUserLesson()
{
return $this->userLesson;
}
/* ****************************** GETTERS & SETTERS ****************************** */
public function getId(): ?int
{
return $this->id;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug($slug): self
{
$this->slug = $slug;
return $this;
}
public function getReminderNewLesson(): ?bool
{
return $this->reminderNewLesson;
}
public function setReminderNewLesson(?bool $reminderNewLesson): self
{
$this->reminderNewLesson = $reminderNewLesson;
return $this;
}
public function getItemOrder(): ?int
{
return $this->itemOrder;
}
public function setItemOrder(int $itemOrder): self
{
$this->itemOrder = $itemOrder;
return $this;
}
public function getShareDate(): ?\DateTimeInterface
{
return $this->shareDate;
}
public function setShareDate(?\DateTimeInterface $shareDate): self
{
$this->shareDate = $shareDate;
return $this;
}
public function getShareDays(): ?int
{
return $this->shareDays;
}
public function setShareDays(?int $shareDays): self
{
$this->shareDays = $shareDays;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getLessonType(): ?LessonType
{
return $this->lessonType;
}
public function setLessonType(?LessonType $lessonType): self
{
$this->lessonType = $lessonType;
return $this;
}
/**
* @return Collection|LessonReminder[]
*/
public function getLessonReminder(): Collection
{
return $this->lessonReminder;
}
public function addLessonReminder(LessonReminder $lessonReminder): self
{
if (!$this->lessonReminder->contains($lessonReminder)) {
$this->lessonReminder[] = $lessonReminder;
$lessonReminder->setLesson($this);
}
return $this;
}
public function removeLessonReminder(LessonReminder $lessonReminder): self
{
if ($this->lessonReminder->contains($lessonReminder)) {
$this->lessonReminder->removeElement($lessonReminder);
// set the owning side to null (unless already changed)
if ($lessonReminder->getLesson() === $this) {
$lessonReminder->setLesson(null);
}
}
return $this;
}
/**
* @return Collection|Package[]
*/
public function getPackage(): Collection
{
return $this->package;
}
public function addPackage(Package $package): self
{
if (!$this->package->contains($package)) {
$this->package[] = $package;
$package->addLesson($this);
}
return $this;
}
public function removePackage(Package $package): self
{
if ($this->package->contains($package)) {
$this->package->removeElement($package);
$package->removeLesson($this);
}
return $this;
}
public function getModule(): ?Module
{
return $this->module;
}
public function setModule(?Module $module): self
{
$this->module = $module;
return $this;
}
public function getAuthor(): ?Author
{
return $this->author;
}
public function setAuthor(?Author $author): self
{
$this->author = $author;
return $this;
}
public function getAdvertisementPhoto(): ?string
{
return $this->advertisementPhoto;
}
public function setAdvertisementPhoto(?string $advertisementPhoto): self
{
$this->advertisementPhoto = $advertisementPhoto;
return $this;
}
public function setAdvertisementPhotoFile(File $advertisementPhotoFile = null)
{
$this->advertisementPhotoFile = $advertisementPhotoFile;
if ($advertisementPhotoFile) {
$this->updatedAt = new \DateTime('now');
}
}
public function getAdvertisementPhotoFile()
{
return $this->advertisementPhotoFile;
}
public function getAdvertisementVideoLink(): ?string
{
return $this->advertisementVideoLink;
}
public function setAdvertisementVideoLink(?string $advertisementVideoLink): self
{
$this->advertisementVideoLink = $advertisementVideoLink;
return $this;
}
public function getVideoId(): ?int
{
return $this->videoId;
}
public function setVideoId(?int $videoId): self
{
$this->videoId = $videoId;
return $this;
}
/**
* @return Collection|UserVideoNotes[]
*/
public function getUserVideoNotes(): Collection
{
return $this->userVideoNotes;
}
public function addUserVideoNote(UserVideoNotes $userVideoNote): self
{
if (!$this->userVideoNotes->contains($userVideoNote)) {
$this->userVideoNotes[] = $userVideoNote;
$userVideoNote->setLession($this);
}
return $this;
}
public function removeUserVideoNote(UserVideoNotes $userVideoNote): self
{
if ($this->userVideoNotes->contains($userVideoNote)) {
$this->userVideoNotes->removeElement($userVideoNote);
// set the owning side to null (unless already changed)
if ($userVideoNote->getLession() === $this) {
$userVideoNote->setLession(null);
}
}
return $this;
}
public function getLinkToAdvertisementPhoto(): ?string
{
return $this->linkToAdvertisementPhoto;
}
public function setLinkToAdvertisementPhoto(?string $linkToAdvertisementPhoto): self
{
$this->linkToAdvertisementPhoto = $linkToAdvertisementPhoto;
return $this;
}
public function getLinkToAdvertisementVideo(): ?string
{
return $this->linkToAdvertisementVideo;
}
public function setLinkToAdvertisementVideo(?string $linkToAdvertisementVideo): self
{
$this->linkToAdvertisementVideo = $linkToAdvertisementVideo;
return $this;
}
public function getVisibleAfterDays(): ?int
{
return $this->visibleAfterDays;
}
public function setVisibleAfterDays(int $visibleAfterDays): self
{
$this->visibleAfterDays = $visibleAfterDays;
return $this;
}
}