<?php
namespace EADPlataforma\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use EADPlataforma\Validator\Constraints as EADAssert;
use EADPlataforma\Services\FileService;
use EADPlataforma\Util\DateTimeUtil;
use EADPlataforma\Util\StringUtil;
use EADPlataforma\Enum\CourseEnum;
use \DateTime;
/**
* Course
*
* @ORM\Table(name="course", indexes={
* @ORM\Index(name="fk_course_category_id", columns={"category_id"}),
* @ORM\Index(name="fk_course_user_id", columns={"user_id"}),
* @ORM\Index(name="fk_course_course_certificate_template_id", columns={"course_certificate_template_id"}),
* @ORM\Index(name="fk_course_user_delete_id", columns={"user_delete_id"})
* })
*
* @ORM\Entity(repositoryClass="EADPlataforma\Repository\CourseRepository")
*/
class Course
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @Assert\NotBlank(
* message = "Deleted not informed"
* )
*
* @Assert\Choice(
* choices = {
* CourseEnum::ITEM_NO_DELETED,
* CourseEnum::ITEM_ON_TRASH,
* CourseEnum::ITEM_DELETED
* },
* message = "Delete Option Invalid"
* )
*
* @var int
*
* @ORM\Column(name="deleted", type="integer", nullable=false, options={"default"="0"})
*/
private $deleted = CourseEnum::ITEM_NO_DELETED;
/**
* @Assert\NotBlank(
* message = "Order not informed"
* )
*
* @var int
*
* @ORM\Column(name="`order`", type="integer", nullable=false)
*/
private $order;
/**
* @Assert\NotBlank(
* message = "Title not informed"
* )
*
* @Assert\Length(
* min = 0,
* max = 125
* )
*
* @var string
*
* @ORM\Column(name="title", type="string", length=130, nullable=false)
*/
private $title;
/**
* @Assert\NotBlank(
* message = "Certificate not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Certificate Invalid"
* )
*
* @var int
*
* @ORM\Column(name="certificate", type="integer", nullable=false, options={"default"="0"})
*/
private $certificate = CourseEnum::NO;
/**
* @var decimal|null
*
* @ORM\Column(name="certificate_average", type="decimal", precision=10, scale=2, nullable=true)
*/
private $certificateAverage;
/**
* @Assert\NotBlank(
* message = "Certificate Period not informed"
* )
*
* @var int
*
* @ORM\Column(name="certificate_period", type="integer", nullable=false, options={"default"="0"})
*/
private $certificatePeriod = CourseEnum::NO;
/**
* @var int
*
* @ORM\Column(name="config_period_min_conclusion", type="integer", nullable=true)
*/
private $configPeriodMinConclusion;
/**
* @EADAssert\DateTimeEAD(
* message = "Release Date Invalid"
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="date_release", type="datetime", nullable=false)
*/
private $dateRelease;
/**
* @EADAssert\DateTimeEAD(
* message = "Date Update Invalid"
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="date_update", type="datetime", nullable=false)
*/
private $dateUpdate;
/**
* @var string|null
*
* @Assert\Length(
* min = 0,
* max = 255
* )
*
* @ORM\Column(name="photo", type="string", length=255, nullable=true)
*/
private $photo;
/**
* @var string|null
*
* @Assert\Length(
* min = 0,
* max = 255
* )
*
* @ORM\Column(name="cover", type="string", length=255, nullable=true)
*/
private $cover;
/**
* @Assert\NotBlank(
* message = "Support not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Support Invalid"
* )
*
* @var int
*
* @ORM\Column(name="support", type="integer", nullable=false, options={"default"="0"})
*/
private $support = CourseEnum::NO;
/**
* @Assert\NotBlank(
* message = "Support period not informed"
* )
*
* @var int
*
* @ORM\Column(name="support_period", type="integer", nullable=false, options={"default"="0"})
*/
private $supportPeriod = '0';
/**
* @Assert\NotBlank(
* message = "Lifetime Support not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Lifetime Support Invalid"
* )
*
* @var int
*
* @ORM\Column(name="lifetime_support", type="integer", nullable=false, options={"default"="0"})
*/
private $lifetimeSupport = CourseEnum::NO;
/**
* @var string|null
*
* @ORM\Column(name="workload", type="string", length=10, nullable=true)
*/
private $workload;
/**
* @Assert\NotBlank(
* message = "Status not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::DRAFT, CourseEnum::PUBLISHED },
* message = "Status Invalid"
* )
*
* @var int
*
* @ORM\Column(name="status", type="integer", nullable=false, options={"default"="0"})
*/
private $status = CourseEnum::DRAFT;
/**
* @Assert\NotBlank(
* message = "Free not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Free Invalid"
* )
*
* @var int
*
* @ORM\Column(name="free", type="integer", nullable=false, options={"default"="0"})
*/
private $free = CourseEnum::NO;
/**
* @Assert\NotBlank(
* message = "Access Period informed"
* )
*
* @var int
*
* @ORM\Column(name="access_period", type="integer", nullable=false, options={"default"="0"})
*/
private $accessPeriod = '0';
/**
* @Assert\NotBlank(
* message = "Lifetime Period not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Lifetime Period Invalid"
* )
*
* @var int
*
* @ORM\Column(name="lifetime_period", type="integer", nullable=false, options={"default"="0"})
*/
private $lifetimePeriod = CourseEnum::NO;
/**
* @var int
*
* @ORM\Column(name="number_lesson", type="integer", nullable=false, options={"default"="0"})
*/
private $numberLesson = '0';
/**
* @Assert\NotBlank(
* message = "Control Lesson Requirement not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Control Lesson Requirement Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_requirement", type="integer", nullable=false, options={"default"="0"})
*/
private $controlLessonRequirement = CourseEnum::NO;
/**
* @Assert\NotBlank(
* message = "Control Lesson Release Type not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::LESSON_RELEASED, CourseEnum::LESSON_FIXED_DATE, CourseEnum::LESSON_FLEXIBLE_DATE },
* message = "Control Lesson Release Type Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_release_type", type="integer", nullable=false, options={"default"="0"})
*/
private $controlLessonReleaseType = CourseEnum::LESSON_RELEASED;
/**
* @Assert\NotBlank(
* message = "Control Lesson After Type not informed",
* groups = "controlReleaseTypeFlex",
* )
*
* @Assert\Choice(
* choices = { CourseEnum::LESSON_ENROLLMENT, CourseEnum::LESSON_LAST_LESSON },
* message = "Control Lesson After Type Invalid",
* groups = "controlReleaseTypeFlex",
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_after_type", type="integer", nullable=false, options={"default"="1"})
*/
private $controlLessonAfterType = CourseEnum::LESSON_LAST_LESSON;
/**
* @Assert\NotBlank(
* message = "Control Release Date not informed",
* groups = "controlReleaseTypeFixed",
* )
*
* @EADAssert\DateTimeEAD(
* message = "Control Lesson Release Date Invalid",
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="control_lesson_date_release", type="datetime", nullable=true)
*/
private $controlLessonDateRelease;
/**
* @Assert\NotBlank(
* message = "Control Release Period not informed",
* groups = "controlReleaseTypeFlex",
* )
*
* @var int|null
*
* @ORM\Column(name="control_lesson_release_period", type="integer", nullable=true)
*/
private $controlLessonReleasePeriod;
/**
* @var int|null
*
* @ORM\Column(name="control_lesson_close_period", type="integer", nullable=true)
*/
private $controlLessonClosePeriod;
/**
* @Assert\NotBlank(
* message = "Control Lesson Time not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Control Lesson Time Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_time", type="integer", nullable=false, options={"default"="0"})
*/
private $controlLessonTime = CourseEnum::NO;
/**
* @EADAssert\TimeEAD(
* message = "Control Lesson Time Stay Invalid"
* )
*
* @Assert\NotEqualTo(
* value = "00:00:00",
* message = "Control Lesson Time not informed"
* )
*
* @var Time|null
*
* @ORM\Column(name="control_lesson_time_stay", type="string", length=10, nullable=true)
*/
private $controlLessonTimeStay;
/**
* @Assert\NotBlank(
* message = "Control Lesson View Limit not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Control Lesson View Limit Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_view_limit", type="integer", nullable=false, options={"default"="0"})
*/
private $controlLessonViewLimit = CourseEnum::NO;
/**
* @Assert\NotBlank(
* message = "Control Lesson View Number not informed",
* groups = "limitedView",
* )
*
* @Assert\GreaterThanOrEqual(
* value = 1,
* message = "Control Lesson View Number invalid",
* groups = "limitedView",
* )
*
* @var int|null
*
* @ORM\Column(name="control_lesson_view_number", type="integer", nullable=true)
*/
private $controlLessonViewNumber;
/**
* @Assert\NotBlank(
* message = "Control Lesson Show Document not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::NO, CourseEnum::YES },
* message = "Control Lesson Show Document Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_show_document", type="integer", nullable=false, options={"default"="0"})
*/
private $controlLessonShowDocument = CourseEnum::NO;
/**
* @Assert\NotBlank(
* message = "Control Lesson Apply not informed"
* )
*
* @Assert\Choice(
* choices = { CourseEnum::ALL_LESSONS, CourseEnum::ONLY_NEW_LESSONS, CourseEnum::ONLY_EXIST_LESSONS },
* message = "Control Lesson Apply Invalid"
* )
*
* @var int
*
* @ORM\Column(name="control_lesson_apply", type="integer", nullable=false, options={"default"="1"})
*/
private $controlLessonApply = CourseEnum::ALL_LESSONS;
/**
* @Assert\Valid
*
* @var \CourseCertificateTemplate
*
* @ORM\ManyToOne(targetEntity="CourseCertificateTemplate")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="course_certificate_template_id", referencedColumnName="id")
* })
*/
private $courseCertificateTemplate;
/**
* @Assert\NotBlank(
* message = "Category not informed"
* )
*
* @Assert\Valid
*
* @var \Category
*
* @ORM\ManyToOne(targetEntity="Category")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false)
* })
*/
private $category;
/**
* @Assert\NotBlank(
* message = "User not informed"
* )
*
* @Assert\Valid
*
* @var \User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
* })
*/
private $user;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Group", mappedBy="course")
*/
private $group;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Product", mappedBy="course")
*/
private $product;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Cart", mappedBy="course")
*/
private $cart;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="TransactionItem", mappedBy="course")
*/
private $transactionItem;
/**
* @Assert\Valid
*
* @var \EADPlataforma\Entity\User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user_delete_id", referencedColumnName="id", nullable=true)
* })
*/
private $userDelete;
/**
* @Assert\Choice(
* choices = {
* CourseEnum::INDIVIDUAL,
* CourseEnum::CASCADE
* },
* message = "Type Delete Invalid"
* )
*
* @var int
*
* @ORM\Column(name="type_delete", type="integer", nullable=true)
*/
private $typeDelete;
/**
* @EADAssert\DateTimeEAD(
* message = "Date Delete Invalid"
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="date_delete", type="datetime", nullable=true)
*/
private $dateDelete;
/**
* Constructor
*/
public function __construct()
{
$this->group = new \Doctrine\Common\Collections\ArrayCollection();
$this->product = new \Doctrine\Common\Collections\ArrayCollection();
$this->cart = new \Doctrine\Common\Collections\ArrayCollection();
$this->transactionItem = new \Doctrine\Common\Collections\ArrayCollection();
$this->dateRelease = new DateTime();
$this->dateUpdate = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getOrder(): ?int
{
return $this->order;
}
public function setOrder(int $order): self
{
$this->order = $order;
return $this;
}
public function getTitle(): ?string
{
return StringUtil::fromUnicode(StringUtil::encodeStringStatic($this->title));
}
public function setTitle(string $title): self
{
$this->title = StringUtil::toUnicode($title);
return $this;
}
public function getCertificate(): ?int
{
return $this->certificate;
}
public function setCertificate(int $certificate): self
{
$this->certificate = $certificate;
return $this;
}
public function getCertificateAverage()
{
return (float)$this->certificateAverage;
}
public function setCertificateAverage($certificateAverage): self
{
$this->certificateAverage = (float)$certificateAverage;
return $this;
}
public function getCertificatePeriod(): ?int
{
return $this->certificatePeriod;
}
public function setCertificatePeriod(int $certificatePeriod): self
{
$this->certificatePeriod = $certificatePeriod;
return $this;
}
public function getConfigPeriodMinConclusion(): ?int
{
return $this->configPeriodMinConclusion;
}
public function setConfigPeriodMinConclusion(int $configPeriodMinConclusion): self
{
$this->configPeriodMinConclusion = $configPeriodMinConclusion;
return $this;
}
public function getDateRelease($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->dateRelease)){
return $this->dateRelease->format($dateFormat);
}
return $this->dateRelease;
}
public function setDateRelease($dateRelease): self
{
if(!empty($dateRelease)){
$dateRelease = DateTime::createFromFormat('Y-m-d H:i:s', $dateRelease);
}
$this->dateRelease = $dateRelease;
return $this;
}
public function getDateUpdate($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->dateUpdate)){
return $this->dateUpdate->format($dateFormat);
}
return $this->dateUpdate;
}
public function setDateUpdate($dateUpdate): self
{
if(!empty($dateUpdate)){
$dateUpdate = DateTime::createFromFormat('Y-m-d H:i:s', $dateUpdate);
}
$this->dateUpdate = $dateUpdate;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getCover(): ?string
{
return $this->cover;
}
public function setCover(?string $cover): self
{
$this->cover = $cover;
return $this;
}
public function getSupport(): ?int
{
return $this->support;
}
public function setSupport(int $support): self
{
$this->support = $support;
return $this;
}
public function getSupportPeriod(): ?int
{
return $this->supportPeriod;
}
public function setSupportPeriod(int $supportPeriod): self
{
$this->supportPeriod = $supportPeriod;
return $this;
}
public function getLifetimeSupport(): ?int
{
return $this->lifetimeSupport;
}
public function setLifetimeSupport(int $lifetimeSupport): self
{
$this->lifetimeSupport = $lifetimeSupport;
return $this;
}
public function getWorkload(): ?string
{
return $this->workload;
}
public function setWorkload(?string $workload): self
{
$this->workload = $workload;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getFree(): ?int
{
return $this->free;
}
public function setFree(int $free): self
{
$this->free = $free;
return $this;
}
public function getAccessPeriod(): ?int
{
return $this->accessPeriod;
}
public function setAccessPeriod(int $accessPeriod): self
{
$this->accessPeriod = $accessPeriod;
return $this;
}
public function getLifetimePeriod(): ?int
{
return $this->lifetimePeriod;
}
public function setLifetimePeriod(int $lifetimePeriod): self
{
$this->lifetimePeriod = $lifetimePeriod;
return $this;
}
public function getNumberLesson(): ?int
{
return $this->numberLesson;
}
public function setNumberLesson(int $numberLesson): self
{
$this->numberLesson = $numberLesson;
return $this;
}
public function getControlLessonRequirement(): ?int
{
return $this->controlLessonRequirement;
}
public function setControlLessonRequirement(int $controlLessonRequirement): self
{
$this->controlLessonRequirement = $controlLessonRequirement;
return $this;
}
public function getControlLessonReleaseType(): ?int
{
return $this->controlLessonReleaseType;
}
public function setControlLessonReleaseType(int $controlLessonReleaseType): self
{
$this->controlLessonReleaseType = $controlLessonReleaseType;
return $this;
}
public function getControlLessonAfterType(): ?int
{
return $this->controlLessonAfterType;
}
public function setControlLessonAfterType(int $controlLessonAfterType): self
{
$this->controlLessonAfterType = $controlLessonAfterType;
return $this;
}
public function getControlLessonDateRelease($dateFormat = 'Y-m-d H:i:s')
{
if($this->controlLessonDateRelease){
return $this->controlLessonDateRelease->format($dateFormat);
}
return $this->controlLessonDateRelease;
}
public function setControlLessonDateRelease($controlLessonDateRelease): self
{
if($controlLessonDateRelease){
$controlLessonDateRelease = DateTime::createFromFormat('Y-m-d H:i:s', $controlLessonDateRelease);
}
$this->controlLessonDateRelease = $controlLessonDateRelease;
return $this;
}
public function getControlLessonReleasePeriod(): ?int
{
return $this->controlLessonReleasePeriod;
}
public function setControlLessonReleasePeriod(?int $controlLessonReleasePeriod): self
{
$this->controlLessonReleasePeriod = $controlLessonReleasePeriod;
return $this;
}
public function getControlLessonClosePeriod(): ?int
{
return $this->controlLessonClosePeriod;
}
public function setControlLessonClosePeriod(?int $controlLessonClosePeriod): self
{
$this->controlLessonClosePeriod = $controlLessonClosePeriod;
return $this;
}
public function getControlLessonTime(): ?int
{
return $this->controlLessonTime;
}
public function setControlLessonTime(int $controlLessonTime): self
{
$this->controlLessonTime = $controlLessonTime;
return $this;
}
public function getControlLessonTimeStay(): ?string
{
return $this->controlLessonTimeStay;
}
public function setControlLessonTimeStay(?string $controlLessonTimeStay): self
{
$this->controlLessonTimeStay = $controlLessonTimeStay;
return $this;
}
public function getControlLessonViewLimit(): ?int
{
return $this->controlLessonViewLimit;
}
public function setControlLessonViewLimit(int $controlLessonViewLimit): self
{
$this->controlLessonViewLimit = $controlLessonViewLimit;
return $this;
}
public function getControlLessonViewNumber(): ?int
{
return $this->controlLessonViewNumber;
}
public function setControlLessonViewNumber(int $controlLessonViewNumber): self
{
$this->controlLessonViewNumber = $controlLessonViewNumber;
return $this;
}
public function getControlLessonShowDocument(): ?int
{
return $this->controlLessonShowDocument;
}
public function setControlLessonShowDocument(int $controlLessonShowDocument): self
{
$this->controlLessonShowDocument = $controlLessonShowDocument;
return $this;
}
public function getControlLessonApply(): ?int
{
return $this->controlLessonApply;
}
public function setControlLessonApply(int $controlLessonApply): self
{
$this->controlLessonApply = $controlLessonApply;
return $this;
}
public function getCourseCertificateTemplate(): ?CourseCertificateTemplate
{
return $this->courseCertificateTemplate;
}
public function setCourseCertificateTemplate(?CourseCertificateTemplate $courseCertificateTemplate): self
{
$this->courseCertificateTemplate = $courseCertificateTemplate;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getUserDelete(): ?User
{
return $this->userDelete;
}
public function setUserDelete(?User $userDelete): self
{
$this->userDelete = $userDelete;
return $this;
}
public function getDateDelete($dateFormat = 'Y-m-d H:i:s')
{
if($this->dateDelete){
return $this->dateDelete->format($dateFormat);
}
return $this->dateDelete;
}
public function setDateDelete($dateDelete): self
{
if(!empty($dateDelete)){
$dateDelete = DateTime::createFromFormat('Y-m-d H:i:s', $dateDelete);
}
$this->dateDelete = $dateDelete;
return $this;
}
/**
* @return Collection|Group[]
*/
public function getGroup(): Collection
{
return $this->group;
}
public function addGroup(Group $group): self
{
if (!$this->group->contains($group)) {
$this->group[] = $group;
$group->addCourse($this);
}
return $this;
}
public function removeGroup(Group $group): self
{
if ($this->group->contains($group)) {
$this->group->removeElement($group);
$group->removeCourse($this);
}
return $this;
}
public function removeAllGroup(): self
{
foreach ($this->group as $key => $group) {
$this->removeGroup($group);
}
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProduct(): Collection
{
return $this->product;
}
public function addProduct(Product $product): self
{
if (!$this->product->contains($product)) {
$this->product[] = $product;
$product->addCourse($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->product->contains($product)) {
$this->product->removeElement($product);
$product->removeCourse($this);
}
return $this;
}
public function removeAllProduct(): self
{
foreach ($this->product as $key => $product) {
$this->removeProduct($product);
}
return $this;
}
/**
* @return Collection|Cart[]
*/
public function getCart(): Collection
{
return $this->cart;
}
public function addCart(Cart $cart): self
{
if (!$this->cart->contains($cart)) {
$this->cart[] = $cart;
$cart->addCourse($this);
}
return $this;
}
public function removeCart(Cart $cart): self
{
if ($this->cart->contains($cart)) {
$this->cart->removeElement($cart);
$cart->removeCourse($this);
}
return $this;
}
public function removeAllCart(): self
{
foreach ($this->cart as $key => $cart) {
$this->removeCart($cart);
}
return $this;
}
/**
* @return Collection|TransactionItem[]
*/
public function getTransactionItem(): Collection
{
return $this->transactionItem;
}
public function addTransactionItem(TransactionItem $transactionItem): self
{
if (!$this->transactionItem->contains($transactionItem)) {
$this->transactionItem[] = $transactionItem;
$transactionItem->addCourse($this);
}
return $this;
}
public function removeTransactionItem(TransactionItem $transactionItem): self
{
if ($this->transactionItem->contains($transactionItem)) {
$this->transactionItem->removeElement($transactionItem);
$transactionItem->removeCourse($this);
}
return $this;
}
public function removeAllTransactionItem(): self
{
foreach ($this->transactionItem as $key => $transactionItem) {
$this->removeTransactionItem($transactionItem);
}
return $this;
}
public function individual(): self
{
$this->typeDelete = CourseEnum::INDIVIDUAL;
return $this;
}
public function cascade(): self
{
$this->typeDelete = CourseEnum::CASCADE;
return $this;
}
public function isLive(): bool
{
return ($this->deleted == CourseEnum::ITEM_NO_DELETED);
}
public function isOnTrash(): bool
{
return ($this->deleted == CourseEnum::ITEM_ON_TRASH);
}
public function isDeleted(): bool
{
return ($this->deleted == CourseEnum::ITEM_DELETED);
}
public function restore(): self
{
$this->deleted = CourseEnum::ITEM_NO_DELETED;
return $this;
}
public function trash(): self
{
$this->deleted = CourseEnum::ITEM_ON_TRASH;
return $this;
}
public function delete(): self
{
$this->deleted = CourseEnum::ITEM_DELETED;
return $this;
}
public function isPublic(): bool
{
return ($this->status == CourseEnum::PUBLISHED);
}
public function toReturn(){
$arrGroup = [];
foreach ($this->group as $key => $group) {
$arrGroup[] = $group->getId();
}
$arrProduct = [];
foreach ($this->product as $key => $product) {
$arrProduct[] = $product->getId();
}
$arrCart = [];
foreach ($this->cart as $key => $cart) {
$arrCart[] = $cart->getId();
}
$data = [
"id" => $this->id,
"deleted" => $this->deleted,
"order" => $this->order,
"title" => $this->getTitle(),
"certificate" => $this->certificate,
"certificateAverage" => $this->certificateAverage,
"dateRelease" => $this->getDateRelease(),
"dateUpdate" => $this->getDateUpdate(),
"photo" => FileService::getFilePathComplete(
$this->photo, CourseEnum::PATH_STORE,
true,
true
),
"cover" => FileService::getFilePathComplete(
$this->cover,
CourseEnum::PATH_COVERS,
true,
true
),
"support" => $this->support,
"supportPeriod" => $this->supportPeriod,
"lifetimeSupport" => $this->lifetimeSupport,
"workload" => $this->workload,
"status" => $this->status,
"free" => $this->free,
"accessPeriod" => $this->accessPeriod,
"lifetimePeriod" => $this->lifetimePeriod,
"numberLesson" => $this->numberLesson,
"controlLessonRequirement" => $this->controlLessonRequirement,
"controlLessonReleaseType" => $this->controlLessonReleaseType,
"controlLessonAfterType" => $this->controlLessonAfterType,
"controlLessonDateRelease" => $this->getControlLessonDateRelease(),
"controlLessonReleasePeriod" => $this->controlLessonReleasePeriod,
"controlLessonClosePeriod" => $this->controlLessonClosePeriod,
"controlLessonTime" => $this->controlLessonTime,
"controlLessonTimeStay" => $this->getControlLessonTimeStay(),
"controlLessonViewLimit" => $this->controlLessonViewLimit,
"controlLessonViewNumber" => $this->controlLessonViewNumber,
"controlLessonShowDocument" => $this->controlLessonShowDocument,
"controlLessonApply" => $this->controlLessonApply,
"courseCertificateTemplate" => (
$this->courseCertificateTemplate ?
$this->courseCertificateTemplate->getId() :
null
),
"configPeriodMinConclusion" => $this->configPeriodMinConclusion,
"certificatePeriod" => $this->certificatePeriod,
"courseCategory" => ( $this->category ? $this->category->getId() : null ),
"user" => ( $this->user ? $this->user->getId() : null ),
"userName" => ( $this->user ? $this->user->getName() : null ),
"userPhoto" => (
$this->user ?
FileService::getFilePathComplete(
$this->user->getPhoto(),
CourseEnum::PATH_PROFILES,
true,
true
)
: null
),
"userUsername" => ( $this->user ? $this->user->getUsername() : null ),
"group" => $arrGroup,
"product" => $arrProduct,
"cart" => $arrCart,
"userDelete" => ( $this->userDelete ? $this->userDelete->getId() : null ),
"typeDelete" => $this->typeDelete,
"dateDelete" => $this->getDateDelete()
];
return $data;
}
public function toReturnApi(){
$data = [
"id" => $this->id,
"ordem_curso" => $this->order,
"curso_titulo" => $this->getTitle(),
"emitir_certificado" => $this->certificate,
"media_emitir" => $this->certificateAverage,
"data_lancamento" => $this->getDateRelease(),
"data_atualizacao" => $this->getDateUpdate(),
"foto" => FileService::getFilePathComplete(
$this->photo, CourseEnum::PATH_STORE,
true,
true
),
"cover" => FileService::getFilePathComplete(
$this->cover,
CourseEnum::PATH_COVERS,
true,
true
),
"suporte" => $this->support,
"suporte_vitalicio" => $this->lifetimeSupport,
"carga_horaria" => $this->workload,
"status" => $this->status,
"liberado" => $this->free,
"periodo_acesso" => $this->accessPeriod,
"vitalicio" => $this->lifetimePeriod,
"acesso_vitalicio" => $this->lifetimePeriod,
"certificado_template_id" => (
$this->courseCertificateTemplate ?
$this->courseCertificateTemplate->getId() :
null
),
"categoria_id" => ( $this->category ? $this->category->getId() : null ),
"professor_id" => ( $this->user ? $this->user->getId() : null ),
"nome_professor" => ( $this->user ? $this->user->getName() : null ),
"foto_professor" => (
$this->user ?
FileService::getFilePathComplete(
$this->user->getPhoto(),
CourseEnum::PATH_PROFILES,
true,
true
)
: null
),
];
return $data;
}
}