src/Entity/Course.php line 619

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use EADPlataforma\Validator\Constraints as EADAssert;
  7. use EADPlataforma\Services\FileService;
  8. use EADPlataforma\Util\DateTimeUtil;
  9. use EADPlataforma\Util\StringUtil;
  10. use EADPlataforma\Enum\CourseEnum;
  11. use \DateTime;
  12. /**
  13.  * Course
  14.  *
  15.  * @ORM\Table(name="course", indexes={
  16.  *      @ORM\Index(name="fk_course_category_id", columns={"category_id"}), 
  17.  *      @ORM\Index(name="fk_course_user_id", columns={"user_id"}), 
  18.  *      @ORM\Index(name="fk_course_course_certificate_template_id", columns={"course_certificate_template_id"}),
  19.  *      @ORM\Index(name="fk_course_user_delete_id", columns={"user_delete_id"})
  20.  * })
  21.  *
  22.  * @ORM\Entity(repositoryClass="EADPlataforma\Repository\CourseRepository")
  23.  */
  24. class Course
  25. {
  26.     /**
  27.      * @var int
  28.      *
  29.      * @ORM\Column(name="id", type="integer", nullable=false)
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue(strategy="IDENTITY")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @Assert\NotBlank(
  36.      *      message = "Deleted not informed"
  37.      * )
  38.      *
  39.      * @Assert\Choice(
  40.      *      choices = { 
  41.      *                      CourseEnum::ITEM_NO_DELETED, 
  42.      *                      CourseEnum::ITEM_ON_TRASH,
  43.      *                      CourseEnum::ITEM_DELETED
  44.      *                },
  45.      *      message = "Delete Option Invalid"
  46.      * )
  47.      *
  48.      * @var int
  49.      *
  50.      * @ORM\Column(name="deleted", type="integer", nullable=false, options={"default"="0"})
  51.      */
  52.     private $deleted CourseEnum::ITEM_NO_DELETED;
  53.     /**
  54.      * @Assert\NotBlank(
  55.      *      message = "Order not informed"
  56.      * )
  57.      *
  58.      * @var int
  59.      *
  60.      * @ORM\Column(name="`order`", type="integer", nullable=false)
  61.      */
  62.     private $order;
  63.     /**
  64.      * @Assert\NotBlank(
  65.      *      message = "Title not informed"
  66.      * )
  67.      * 
  68.      * @Assert\Length(
  69.      *      min = 0,
  70.      *      max = 125
  71.      * )
  72.      *
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="title", type="string", length=130, nullable=false)
  76.      */
  77.     private $title;
  78.     /**
  79.      * @Assert\NotBlank(
  80.      *      message = "Certificate not informed"
  81.      * )
  82.      *
  83.      * @Assert\Choice(
  84.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  85.      *      message = "Certificate Invalid"
  86.      * )
  87.      *
  88.      * @var int
  89.      *
  90.      * @ORM\Column(name="certificate", type="integer", nullable=false, options={"default"="0"})
  91.      */
  92.     private $certificate CourseEnum::NO;
  93.     /**
  94.      * @var decimal|null
  95.      *
  96.      * @ORM\Column(name="certificate_average", type="decimal", precision=10, scale=2, nullable=true)
  97.      */
  98.     private $certificateAverage;
  99.     /**
  100.      * @Assert\NotBlank(
  101.      *      message = "Certificate Period not informed"
  102.      * )
  103.      * 
  104.      * @var int
  105.      *
  106.      * @ORM\Column(name="certificate_period", type="integer", nullable=false, options={"default"="0"})
  107.      */
  108.     private $certificatePeriod =  CourseEnum::NO;
  109.     /**
  110.      * @var int
  111.      *
  112.      * @ORM\Column(name="config_period_min_conclusion", type="integer", nullable=true)
  113.      */
  114.     private $configPeriodMinConclusion;
  115.     /**
  116.      * @EADAssert\DateTimeEAD(
  117.      *      message = "Release Date Invalid"
  118.      * )
  119.      *
  120.      * @var \DateTime|null
  121.      *
  122.      * @ORM\Column(name="date_release", type="datetime", nullable=false)
  123.      */
  124.     private $dateRelease;
  125.     /**
  126.      * @EADAssert\DateTimeEAD(
  127.      *      message = "Date Update Invalid"
  128.      * )
  129.      *
  130.      * @var \DateTime|null
  131.      *
  132.      * @ORM\Column(name="date_update", type="datetime", nullable=false)
  133.      */
  134.     private $dateUpdate;
  135.     /**
  136.      * @var string|null
  137.      * 
  138.      * @Assert\Length(
  139.      *      min = 0,
  140.      *      max = 255
  141.      * )
  142.      *
  143.      * @ORM\Column(name="photo", type="string", length=255, nullable=true)
  144.      */
  145.     private $photo;
  146.     /**
  147.      * @var string|null
  148.      * 
  149.      * @Assert\Length(
  150.      *      min = 0,
  151.      *      max = 255
  152.      * )
  153.      *
  154.      * @ORM\Column(name="cover", type="string", length=255, nullable=true)
  155.      */
  156.     private $cover;
  157.     /**
  158.      * @Assert\NotBlank(
  159.      *      message = "Support not informed"
  160.      * )
  161.      *
  162.      * @Assert\Choice(
  163.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  164.      *      message = "Support Invalid"
  165.      * )
  166.      *
  167.      * @var int
  168.      *
  169.      * @ORM\Column(name="support", type="integer", nullable=false, options={"default"="0"})
  170.      */
  171.     private $support CourseEnum::NO;
  172.     /**
  173.      * @Assert\NotBlank(
  174.      *      message = "Support period not informed"
  175.      * )
  176.      *
  177.      * @var int
  178.      *
  179.      * @ORM\Column(name="support_period", type="integer", nullable=false, options={"default"="0"})
  180.      */
  181.     private $supportPeriod '0';
  182.     /**
  183.      * @Assert\NotBlank(
  184.      *      message = "Lifetime Support not informed"
  185.      * )
  186.      *
  187.      * @Assert\Choice(
  188.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  189.      *      message = "Lifetime Support Invalid"
  190.      * )
  191.      *
  192.      * @var int
  193.      *
  194.      * @ORM\Column(name="lifetime_support", type="integer", nullable=false, options={"default"="0"})
  195.      */
  196.     private $lifetimeSupport CourseEnum::NO;
  197.     /**
  198.      * @var string|null
  199.      *
  200.      * @ORM\Column(name="workload", type="string", length=10, nullable=true)
  201.      */
  202.     private $workload;
  203.     /**
  204.      * @Assert\NotBlank(
  205.      *      message = "Status not informed"
  206.      * )
  207.      *
  208.      * @Assert\Choice(
  209.      *      choices = { CourseEnum::DRAFT, CourseEnum::PUBLISHED },
  210.      *      message = "Status Invalid"
  211.      * )
  212.      *
  213.      * @var int
  214.      *
  215.      * @ORM\Column(name="status", type="integer", nullable=false, options={"default"="0"})
  216.      */
  217.     private $status CourseEnum::DRAFT;
  218.     /**
  219.      * @Assert\NotBlank(
  220.      *      message = "Free not informed"
  221.      * )
  222.      *
  223.      * @Assert\Choice(
  224.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  225.      *      message = "Free Invalid"
  226.      * )
  227.      *
  228.      * @var int
  229.      *
  230.      * @ORM\Column(name="free", type="integer", nullable=false, options={"default"="0"})
  231.      */
  232.     private $free CourseEnum::NO;
  233.     /**
  234.      * @Assert\NotBlank(
  235.      *      message = "Access Period informed"
  236.      * )
  237.      *
  238.      * @var int
  239.      *
  240.      * @ORM\Column(name="access_period", type="integer", nullable=false, options={"default"="0"})
  241.      */
  242.     private $accessPeriod '0';
  243.     /**
  244.      * @Assert\NotBlank(
  245.      *      message = "Lifetime Period not informed"
  246.      * )
  247.      *
  248.      * @Assert\Choice(
  249.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  250.      *      message = "Lifetime Period Invalid"
  251.      * )
  252.      *
  253.      * @var int
  254.      *
  255.      * @ORM\Column(name="lifetime_period", type="integer", nullable=false, options={"default"="0"})
  256.      */
  257.     private $lifetimePeriod CourseEnum::NO;
  258.     /**
  259.      * @var int
  260.      *
  261.      * @ORM\Column(name="number_lesson", type="integer", nullable=false, options={"default"="0"})
  262.      */
  263.     private $numberLesson '0';
  264.     /**
  265.      * @Assert\NotBlank(
  266.      *      message = "Control Lesson Requirement not informed"
  267.      * )
  268.      *
  269.      * @Assert\Choice(
  270.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  271.      *      message = "Control Lesson Requirement Invalid"
  272.      * )
  273.      *
  274.      * @var int
  275.      *
  276.      * @ORM\Column(name="control_lesson_requirement", type="integer", nullable=false, options={"default"="0"})
  277.      */
  278.     private $controlLessonRequirement CourseEnum::NO;
  279.     /**
  280.      * @Assert\NotBlank(
  281.      *      message = "Control Lesson Release Type not informed"
  282.      * )
  283.      *
  284.      * @Assert\Choice(
  285.      *      choices = { CourseEnum::LESSON_RELEASED, CourseEnum::LESSON_FIXED_DATE, CourseEnum::LESSON_FLEXIBLE_DATE },
  286.      *      message = "Control Lesson Release Type Invalid"
  287.      * )
  288.      *
  289.      * @var int
  290.      *
  291.      * @ORM\Column(name="control_lesson_release_type", type="integer", nullable=false, options={"default"="0"})
  292.      */
  293.     private $controlLessonReleaseType CourseEnum::LESSON_RELEASED;
  294.     /**
  295.      * @Assert\NotBlank(
  296.      *      message = "Control Lesson After Type not informed",
  297.      *      groups  = "controlReleaseTypeFlex",
  298.      * )
  299.      *
  300.      * @Assert\Choice(
  301.      *      choices = { CourseEnum::LESSON_ENROLLMENT, CourseEnum::LESSON_LAST_LESSON },
  302.      *      message = "Control Lesson After Type Invalid",
  303.      *      groups  = "controlReleaseTypeFlex",
  304.      * )
  305.      *
  306.      * @var int
  307.      *
  308.      * @ORM\Column(name="control_lesson_after_type", type="integer", nullable=false, options={"default"="1"})
  309.      */
  310.     private $controlLessonAfterType CourseEnum::LESSON_LAST_LESSON;
  311.     /**
  312.      * @Assert\NotBlank(
  313.      *      message = "Control Release Date not informed",
  314.      *      groups  = "controlReleaseTypeFixed",
  315.      * )
  316.      *
  317.      * @EADAssert\DateTimeEAD(
  318.      *      message = "Control Lesson Release Date Invalid",
  319.      * )
  320.      *
  321.      * @var \DateTime|null
  322.      *
  323.      * @ORM\Column(name="control_lesson_date_release", type="datetime", nullable=true)
  324.      */
  325.     private $controlLessonDateRelease;
  326.     /**
  327.      * @Assert\NotBlank(
  328.      *    message = "Control Release Period not informed",
  329.      *    groups  = "controlReleaseTypeFlex",
  330.      * )
  331.      *
  332.      * @var int|null
  333.      *
  334.      * @ORM\Column(name="control_lesson_release_period", type="integer", nullable=true)
  335.      */
  336.     private $controlLessonReleasePeriod;
  337.     /**
  338.      * @var int|null
  339.      *
  340.      * @ORM\Column(name="control_lesson_close_period", type="integer", nullable=true)
  341.      */
  342.     private $controlLessonClosePeriod;
  343.     /**
  344.      * @Assert\NotBlank(
  345.      *      message = "Control Lesson Time not informed"
  346.      * )
  347.      *
  348.      * @Assert\Choice(
  349.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  350.      *      message = "Control Lesson Time Invalid"
  351.      * )
  352.      *
  353.      * @var int
  354.      *
  355.      * @ORM\Column(name="control_lesson_time", type="integer", nullable=false, options={"default"="0"})
  356.      */
  357.     private $controlLessonTime CourseEnum::NO;
  358.     /**
  359.      * @EADAssert\TimeEAD(
  360.      *    message = "Control Lesson Time Stay Invalid"
  361.      * )
  362.      *
  363.      * @Assert\NotEqualTo(
  364.      *    value   = "00:00:00",
  365.      *    message = "Control Lesson Time not informed"
  366.      * )
  367.      *
  368.      * @var Time|null
  369.      *
  370.      * @ORM\Column(name="control_lesson_time_stay", type="string", length=10, nullable=true)
  371.      */
  372.     private $controlLessonTimeStay;
  373.     /**
  374.      * @Assert\NotBlank(
  375.      *      message = "Control Lesson View Limit not informed"
  376.      * )
  377.      *
  378.      * @Assert\Choice(
  379.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  380.      *      message = "Control Lesson View Limit Invalid"
  381.      * )
  382.      *
  383.      * @var int
  384.      *
  385.      * @ORM\Column(name="control_lesson_view_limit", type="integer", nullable=false, options={"default"="0"})
  386.      */
  387.     private $controlLessonViewLimit CourseEnum::NO;
  388.     /**
  389.      * @Assert\NotBlank(
  390.      *      message = "Control Lesson View Number not informed",
  391.      *      groups  = "limitedView",
  392.      * )
  393.      *
  394.      * @Assert\GreaterThanOrEqual(
  395.      *      value = 1,
  396.      *      message = "Control Lesson View Number invalid",
  397.      *      groups  = "limitedView",
  398.      * )
  399.      *
  400.      * @var int|null
  401.      *
  402.      * @ORM\Column(name="control_lesson_view_number", type="integer", nullable=true)
  403.      */
  404.     private $controlLessonViewNumber;
  405.     /**
  406.      * @Assert\NotBlank(
  407.      *      message = "Control Lesson Show Document not informed"
  408.      * )
  409.      *
  410.      * @Assert\Choice(
  411.      *      choices = { CourseEnum::NO, CourseEnum::YES },
  412.      *      message = "Control Lesson Show Document Invalid"
  413.      * )
  414.      *
  415.      * @var int
  416.      *
  417.      * @ORM\Column(name="control_lesson_show_document", type="integer", nullable=false, options={"default"="0"})
  418.      */
  419.     private $controlLessonShowDocument CourseEnum::NO;
  420.     /**
  421.      * @Assert\NotBlank(
  422.      *      message = "Control Lesson Apply not informed"
  423.      * )
  424.      *
  425.      * @Assert\Choice(
  426.      *      choices = { CourseEnum::ALL_LESSONS, CourseEnum::ONLY_NEW_LESSONS, CourseEnum::ONLY_EXIST_LESSONS },
  427.      *      message = "Control Lesson Apply Invalid"
  428.      * )
  429.      *
  430.      * @var int
  431.      *
  432.      * @ORM\Column(name="control_lesson_apply", type="integer", nullable=false, options={"default"="1"})
  433.      */
  434.     private $controlLessonApply CourseEnum::ALL_LESSONS;
  435.     /**
  436.      * @Assert\Valid
  437.      *
  438.      * @var \CourseCertificateTemplate
  439.      *
  440.      * @ORM\ManyToOne(targetEntity="CourseCertificateTemplate")
  441.      * @ORM\JoinColumns({
  442.      *   @ORM\JoinColumn(name="course_certificate_template_id", referencedColumnName="id")
  443.      * })
  444.      */
  445.     private $courseCertificateTemplate;
  446.     /**
  447.      * @Assert\NotBlank(
  448.      *      message = "Category not informed"
  449.      * )
  450.      *
  451.      * @Assert\Valid
  452.      *
  453.      * @var \Category
  454.      *
  455.      * @ORM\ManyToOne(targetEntity="Category")
  456.      * @ORM\JoinColumns({
  457.      *   @ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false)
  458.      * })
  459.      */
  460.     private $category;
  461.     /**
  462.      * @Assert\NotBlank(
  463.      *      message = "User not informed"
  464.      * )
  465.      *
  466.      * @Assert\Valid
  467.      *
  468.      * @var \User
  469.      *
  470.      * @ORM\ManyToOne(targetEntity="User")
  471.      * @ORM\JoinColumns({
  472.      *   @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
  473.      * })
  474.      */
  475.     private $user;
  476.     /**
  477.      * @var \Doctrine\Common\Collections\Collection
  478.      *
  479.      * @ORM\ManyToMany(targetEntity="Group", mappedBy="course")
  480.      */
  481.     private $group;
  482.     /**
  483.      * @var \Doctrine\Common\Collections\Collection
  484.      *
  485.      * @ORM\ManyToMany(targetEntity="Product", mappedBy="course")
  486.      */
  487.     private $product;
  488.     /**
  489.      * @var \Doctrine\Common\Collections\Collection
  490.      *
  491.      * @ORM\ManyToMany(targetEntity="Cart", mappedBy="course")
  492.      */
  493.     private $cart;
  494.     /**
  495.      * @var \Doctrine\Common\Collections\Collection
  496.      *
  497.      * @ORM\ManyToMany(targetEntity="TransactionItem", mappedBy="course")
  498.      */
  499.     private $transactionItem;
  500.     /**
  501.      * @Assert\Valid
  502.      *
  503.      * @var \EADPlataforma\Entity\User
  504.      *
  505.      * @ORM\ManyToOne(targetEntity="User")
  506.      * @ORM\JoinColumns({
  507.      *   @ORM\JoinColumn(name="user_delete_id", referencedColumnName="id", nullable=true)
  508.      * })
  509.      */
  510.     private $userDelete;
  511.     /**
  512.      * @Assert\Choice(
  513.      *      choices = { 
  514.      *                      CourseEnum::INDIVIDUAL, 
  515.      *                      CourseEnum::CASCADE
  516.      *                },
  517.      *      message = "Type Delete Invalid"
  518.      * )
  519.      *
  520.      * @var int
  521.      *
  522.      * @ORM\Column(name="type_delete", type="integer", nullable=true)
  523.      */
  524.     private $typeDelete;
  525.     /**
  526.      * @EADAssert\DateTimeEAD(
  527.      *      message = "Date Delete Invalid"
  528.      * )
  529.      *
  530.      * @var \DateTime|null
  531.      *
  532.      * @ORM\Column(name="date_delete", type="datetime", nullable=true)
  533.      */
  534.     private $dateDelete;
  535.     /**
  536.      * Constructor
  537.      */
  538.     public function __construct()
  539.     {
  540.         $this->group = new \Doctrine\Common\Collections\ArrayCollection();
  541.         $this->product = new \Doctrine\Common\Collections\ArrayCollection();
  542.         $this->cart = new \Doctrine\Common\Collections\ArrayCollection();
  543.         $this->transactionItem = new \Doctrine\Common\Collections\ArrayCollection();
  544.         $this->dateRelease = new DateTime();
  545.         $this->dateUpdate = new DateTime();
  546.     }
  547.     public function getId(): ?int
  548.     {
  549.         return $this->id;
  550.     }
  551.     public function getOrder(): ?int
  552.     {
  553.         return $this->order;
  554.     }
  555.     public function setOrder(int $order): self
  556.     {
  557.         $this->order $order;
  558.         return $this;
  559.     }
  560.     public function getTitle(): ?string
  561.     {
  562.         return StringUtil::fromUnicode(StringUtil::encodeStringStatic($this->title));
  563.     }
  564.     public function setTitle(string $title): self
  565.     {
  566.         $this->title StringUtil::toUnicode($title);
  567.         return $this;
  568.     }
  569.     public function getCertificate(): ?int
  570.     {
  571.         return $this->certificate;
  572.     }
  573.     public function setCertificate(int $certificate): self
  574.     {
  575.         $this->certificate $certificate;
  576.         return $this;
  577.     }
  578.     public function getCertificateAverage()
  579.     {
  580.         return (float)$this->certificateAverage;
  581.     }
  582.     public function setCertificateAverage($certificateAverage): self
  583.     {
  584.         $this->certificateAverage = (float)$certificateAverage;
  585.         return $this;
  586.     }
  587.     public function getCertificatePeriod(): ?int
  588.     {
  589.         return $this->certificatePeriod;
  590.     }
  591.     public function setCertificatePeriod(int $certificatePeriod): self
  592.     {
  593.         $this->certificatePeriod $certificatePeriod;
  594.         return $this;
  595.     }
  596.     public function getConfigPeriodMinConclusion(): ?int
  597.     {
  598.         return $this->configPeriodMinConclusion;
  599.     }
  600.     public function setConfigPeriodMinConclusion(int $configPeriodMinConclusion): self
  601.     {
  602.         $this->configPeriodMinConclusion $configPeriodMinConclusion;
  603.         return $this;
  604.     }
  605.     public function getDateRelease($dateFormat 'Y-m-d H:i:s')
  606.     {
  607.         if(!empty($this->dateRelease)){
  608.             return $this->dateRelease->format($dateFormat);
  609.         }
  610.         return $this->dateRelease;
  611.     }
  612.     public function setDateRelease($dateRelease): self
  613.     {
  614.         if(!empty($dateRelease)){
  615.             $dateRelease DateTime::createFromFormat('Y-m-d H:i:s'$dateRelease);
  616.         }
  617.         
  618.         $this->dateRelease $dateRelease;
  619.         return $this;
  620.     }
  621.     public function getDateUpdate($dateFormat 'Y-m-d H:i:s')
  622.     {
  623.         if(!empty($this->dateUpdate)){
  624.             return $this->dateUpdate->format($dateFormat);
  625.         }
  626.         return $this->dateUpdate;
  627.     }
  628.     public function setDateUpdate($dateUpdate): self
  629.     {
  630.         if(!empty($dateUpdate)){
  631.             $dateUpdate DateTime::createFromFormat('Y-m-d H:i:s'$dateUpdate);
  632.         }
  633.         
  634.         $this->dateUpdate $dateUpdate;
  635.         return $this;
  636.     }
  637.     public function getPhoto(): ?string
  638.     {
  639.         return $this->photo;
  640.     }
  641.     public function setPhoto(?string $photo): self
  642.     {
  643.         $this->photo $photo;
  644.         return $this;
  645.     }
  646.     public function getCover(): ?string
  647.     {
  648.         return $this->cover;
  649.     }
  650.     public function setCover(?string $cover): self
  651.     {
  652.         $this->cover $cover;
  653.         return $this;
  654.     }
  655.     public function getSupport(): ?int
  656.     {
  657.         return $this->support;
  658.     }
  659.     public function setSupport(int $support): self
  660.     {
  661.         $this->support $support;
  662.         return $this;
  663.     }
  664.     public function getSupportPeriod(): ?int
  665.     {
  666.         return $this->supportPeriod;
  667.     }
  668.     public function setSupportPeriod(int $supportPeriod): self
  669.     {
  670.         $this->supportPeriod $supportPeriod;
  671.         return $this;
  672.     }
  673.     public function getLifetimeSupport(): ?int
  674.     {
  675.         return $this->lifetimeSupport;
  676.     }
  677.     public function setLifetimeSupport(int $lifetimeSupport): self
  678.     {
  679.         $this->lifetimeSupport $lifetimeSupport;
  680.         return $this;
  681.     }
  682.     public function getWorkload(): ?string
  683.     {
  684.         return $this->workload;
  685.     }
  686.     public function setWorkload(?string $workload): self
  687.     {
  688.         $this->workload $workload;
  689.         return $this;
  690.     }
  691.     public function getStatus(): ?int
  692.     {
  693.         return $this->status;
  694.     }
  695.     public function setStatus(int $status): self
  696.     {
  697.         $this->status $status;
  698.         return $this;
  699.     }
  700.     public function getFree(): ?int
  701.     {
  702.         return $this->free;
  703.     }
  704.     public function setFree(int $free): self
  705.     {
  706.         $this->free $free;
  707.         return $this;
  708.     }
  709.     public function getAccessPeriod(): ?int
  710.     {
  711.         return $this->accessPeriod;
  712.     }
  713.     public function setAccessPeriod(int $accessPeriod): self
  714.     {
  715.         $this->accessPeriod $accessPeriod;
  716.         return $this;
  717.     }
  718.     public function getLifetimePeriod(): ?int
  719.     {
  720.         return $this->lifetimePeriod;
  721.     }
  722.     public function setLifetimePeriod(int $lifetimePeriod): self
  723.     {
  724.         $this->lifetimePeriod $lifetimePeriod;
  725.         return $this;
  726.     }
  727.     public function getNumberLesson(): ?int
  728.     {
  729.         return $this->numberLesson;
  730.     }
  731.     public function setNumberLesson(int $numberLesson): self
  732.     {
  733.         $this->numberLesson $numberLesson;
  734.         return $this;
  735.     }
  736.     public function getControlLessonRequirement(): ?int
  737.     {
  738.         return $this->controlLessonRequirement;
  739.     }
  740.     public function setControlLessonRequirement(int $controlLessonRequirement): self
  741.     {
  742.         $this->controlLessonRequirement $controlLessonRequirement;
  743.         return $this;
  744.     }
  745.     public function getControlLessonReleaseType(): ?int
  746.     {
  747.         return $this->controlLessonReleaseType;
  748.     }
  749.     public function setControlLessonReleaseType(int $controlLessonReleaseType): self
  750.     {
  751.         $this->controlLessonReleaseType $controlLessonReleaseType;
  752.         return $this;
  753.     }
  754.     public function getControlLessonAfterType(): ?int
  755.     {
  756.         return $this->controlLessonAfterType;
  757.     }
  758.     public function setControlLessonAfterType(int $controlLessonAfterType): self
  759.     {
  760.         $this->controlLessonAfterType $controlLessonAfterType;
  761.         return $this;
  762.     }
  763.     public function getControlLessonDateRelease($dateFormat 'Y-m-d H:i:s')
  764.     {
  765.         if($this->controlLessonDateRelease){
  766.             return $this->controlLessonDateRelease->format($dateFormat);
  767.         }
  768.         return $this->controlLessonDateRelease;
  769.     }
  770.     public function setControlLessonDateRelease($controlLessonDateRelease): self
  771.     {
  772.         if($controlLessonDateRelease){
  773.             $controlLessonDateRelease DateTime::createFromFormat('Y-m-d H:i:s'$controlLessonDateRelease);
  774.         }
  775.         $this->controlLessonDateRelease $controlLessonDateRelease;
  776.         return $this;
  777.     }
  778.     public function getControlLessonReleasePeriod(): ?int
  779.     {
  780.         return $this->controlLessonReleasePeriod;
  781.     }
  782.     public function setControlLessonReleasePeriod(?int $controlLessonReleasePeriod): self
  783.     {
  784.         $this->controlLessonReleasePeriod $controlLessonReleasePeriod;
  785.         return $this;
  786.     }
  787.     public function getControlLessonClosePeriod(): ?int
  788.     {
  789.         return $this->controlLessonClosePeriod;
  790.     }
  791.     public function setControlLessonClosePeriod(?int $controlLessonClosePeriod): self
  792.     {
  793.         $this->controlLessonClosePeriod $controlLessonClosePeriod;
  794.         return $this;
  795.     }
  796.     public function getControlLessonTime(): ?int
  797.     {
  798.         return $this->controlLessonTime;
  799.     }
  800.     public function setControlLessonTime(int $controlLessonTime): self
  801.     {
  802.         $this->controlLessonTime $controlLessonTime;
  803.         return $this;
  804.     }
  805.     public function getControlLessonTimeStay(): ?string
  806.     {
  807.         return $this->controlLessonTimeStay;
  808.     }
  809.     public function setControlLessonTimeStay(?string $controlLessonTimeStay): self
  810.     {
  811.         $this->controlLessonTimeStay $controlLessonTimeStay;
  812.         return $this;
  813.     }
  814.     public function getControlLessonViewLimit(): ?int
  815.     {
  816.         return $this->controlLessonViewLimit;
  817.     }
  818.     public function setControlLessonViewLimit(int $controlLessonViewLimit): self
  819.     {
  820.         $this->controlLessonViewLimit $controlLessonViewLimit;
  821.         return $this;
  822.     }
  823.     public function getControlLessonViewNumber(): ?int
  824.     {
  825.         return $this->controlLessonViewNumber;
  826.     }
  827.     public function setControlLessonViewNumber(int $controlLessonViewNumber): self
  828.     {
  829.         $this->controlLessonViewNumber $controlLessonViewNumber;
  830.         return $this;
  831.     }
  832.     public function getControlLessonShowDocument(): ?int
  833.     {
  834.         return $this->controlLessonShowDocument;
  835.     }
  836.     public function setControlLessonShowDocument(int $controlLessonShowDocument): self
  837.     {
  838.         $this->controlLessonShowDocument $controlLessonShowDocument;
  839.         return $this;
  840.     }
  841.     public function getControlLessonApply(): ?int
  842.     {
  843.         return $this->controlLessonApply;
  844.     }
  845.     public function setControlLessonApply(int $controlLessonApply): self
  846.     {
  847.         $this->controlLessonApply $controlLessonApply;
  848.         return $this;
  849.     }
  850.     public function getCourseCertificateTemplate(): ?CourseCertificateTemplate
  851.     {
  852.         return $this->courseCertificateTemplate;
  853.     }
  854.     public function setCourseCertificateTemplate(?CourseCertificateTemplate $courseCertificateTemplate): self
  855.     {
  856.         $this->courseCertificateTemplate $courseCertificateTemplate;
  857.         return $this;
  858.     }
  859.     public function getCategory(): ?Category
  860.     {
  861.         return $this->category;
  862.     }
  863.     public function setCategory(?Category $category): self
  864.     {
  865.         $this->category $category;
  866.         return $this;
  867.     }
  868.     public function getUser(): ?User
  869.     {
  870.         return $this->user;
  871.     }
  872.     public function setUser(?User $user): self
  873.     {
  874.         $this->user $user;
  875.         return $this;
  876.     }
  877.     public function getUserDelete(): ?User
  878.     {
  879.         return $this->userDelete;
  880.     }
  881.     public function setUserDelete(?User $userDelete): self
  882.     {
  883.         $this->userDelete $userDelete;
  884.         return $this;
  885.     }
  886.     public function getDateDelete($dateFormat 'Y-m-d H:i:s')
  887.     {
  888.         if($this->dateDelete){
  889.             return $this->dateDelete->format($dateFormat);
  890.         }
  891.         return $this->dateDelete;
  892.     }
  893.     public function setDateDelete($dateDelete): self
  894.     {
  895.         if(!empty($dateDelete)){
  896.             $dateDelete DateTime::createFromFormat('Y-m-d H:i:s'$dateDelete);
  897.         }
  898.         
  899.         $this->dateDelete $dateDelete;
  900.         return $this;
  901.     }
  902.     /**
  903.      * @return Collection|Group[]
  904.      */
  905.     public function getGroup(): Collection
  906.     {
  907.         return $this->group;
  908.     }
  909.     public function addGroup(Group $group): self
  910.     {
  911.         if (!$this->group->contains($group)) {
  912.             $this->group[] = $group;
  913.             $group->addCourse($this);
  914.         }
  915.         return $this;
  916.     }
  917.     public function removeGroup(Group $group): self
  918.     {
  919.         if ($this->group->contains($group)) {
  920.             $this->group->removeElement($group);
  921.             $group->removeCourse($this);
  922.         }
  923.         return $this;
  924.     }
  925.     public function removeAllGroup(): self
  926.     {
  927.         foreach ($this->group as $key => $group) {
  928.             $this->removeGroup($group);
  929.         }
  930.         return $this;
  931.     }
  932.     /**
  933.      * @return Collection|Product[]
  934.      */
  935.     public function getProduct(): Collection
  936.     {
  937.         return $this->product;
  938.     }
  939.     public function addProduct(Product $product): self
  940.     {
  941.         if (!$this->product->contains($product)) {
  942.             $this->product[] = $product;
  943.             $product->addCourse($this);
  944.         }
  945.         return $this;
  946.     }
  947.     public function removeProduct(Product $product): self
  948.     {
  949.         if ($this->product->contains($product)) {
  950.             $this->product->removeElement($product);
  951.             $product->removeCourse($this);
  952.         }
  953.         return $this;
  954.     }
  955.     public function removeAllProduct(): self
  956.     {
  957.         foreach ($this->product as $key => $product) {
  958.             $this->removeProduct($product);
  959.         }
  960.         return $this;
  961.     }
  962.     /**
  963.      * @return Collection|Cart[]
  964.      */
  965.     public function getCart(): Collection
  966.     {
  967.         return $this->cart;
  968.     }
  969.     public function addCart(Cart $cart): self
  970.     {
  971.         if (!$this->cart->contains($cart)) {
  972.             $this->cart[] = $cart;
  973.             $cart->addCourse($this);
  974.         }
  975.         return $this;
  976.     }
  977.     public function removeCart(Cart $cart): self
  978.     {
  979.         if ($this->cart->contains($cart)) {
  980.             $this->cart->removeElement($cart);
  981.             $cart->removeCourse($this);
  982.         }
  983.         return $this;
  984.     }
  985.     public function removeAllCart(): self
  986.     {
  987.         foreach ($this->cart as $key => $cart) {
  988.             $this->removeCart($cart);
  989.         }
  990.         return $this;
  991.     }
  992.     /**
  993.      * @return Collection|TransactionItem[]
  994.      */
  995.     public function getTransactionItem(): Collection
  996.     {
  997.         return $this->transactionItem;
  998.     }
  999.     public function addTransactionItem(TransactionItem $transactionItem): self
  1000.     {
  1001.         if (!$this->transactionItem->contains($transactionItem)) {
  1002.             $this->transactionItem[] = $transactionItem;
  1003.             $transactionItem->addCourse($this);
  1004.         }
  1005.         return $this;
  1006.     }
  1007.     public function removeTransactionItem(TransactionItem $transactionItem): self
  1008.     {
  1009.         if ($this->transactionItem->contains($transactionItem)) {
  1010.             $this->transactionItem->removeElement($transactionItem);
  1011.             $transactionItem->removeCourse($this);
  1012.         }
  1013.         return $this;
  1014.     }
  1015.     public function removeAllTransactionItem(): self
  1016.     {
  1017.         foreach ($this->transactionItem as $key => $transactionItem) {
  1018.             $this->removeTransactionItem($transactionItem);
  1019.         }
  1020.         return $this;
  1021.     }
  1022.     public function individual(): self
  1023.     {
  1024.         $this->typeDelete CourseEnum::INDIVIDUAL;
  1025.         return $this;
  1026.     }
  1027.     public function cascade(): self
  1028.     {
  1029.         $this->typeDelete CourseEnum::CASCADE;
  1030.         return $this;
  1031.     }
  1032.     public function isLive(): bool
  1033.     {
  1034.         return ($this->deleted == CourseEnum::ITEM_NO_DELETED);
  1035.     }
  1036.     public function isOnTrash(): bool
  1037.     {
  1038.         return ($this->deleted == CourseEnum::ITEM_ON_TRASH);
  1039.     }
  1040.     public function isDeleted(): bool
  1041.     {
  1042.         return ($this->deleted == CourseEnum::ITEM_DELETED);
  1043.     }
  1044.     public function restore(): self
  1045.     {
  1046.         $this->deleted CourseEnum::ITEM_NO_DELETED;
  1047.         return $this;
  1048.     }
  1049.     public function trash(): self
  1050.     {
  1051.         $this->deleted CourseEnum::ITEM_ON_TRASH;
  1052.         return $this;
  1053.     }
  1054.     public function delete(): self
  1055.     {
  1056.         $this->deleted CourseEnum::ITEM_DELETED;
  1057.         return $this;
  1058.     }
  1059.     public function isPublic(): bool
  1060.     {
  1061.         return ($this->status == CourseEnum::PUBLISHED);
  1062.     }
  1063.     public function toReturn(){
  1064.         $arrGroup = [];
  1065.         foreach ($this->group as $key => $group) {
  1066.             $arrGroup[] = $group->getId();
  1067.         }
  1068.         $arrProduct = [];
  1069.         foreach ($this->product as $key => $product) {
  1070.             $arrProduct[] = $product->getId();
  1071.         }
  1072.         $arrCart = [];
  1073.         foreach ($this->cart as $key => $cart) {
  1074.             $arrCart[] = $cart->getId();
  1075.         }
  1076.         $data = [
  1077.             "id" => $this->id,
  1078.             "deleted" => $this->deleted,
  1079.             "order" => $this->order,
  1080.             "title" => $this->getTitle(),
  1081.             "certificate" => $this->certificate,
  1082.             "certificateAverage" => $this->certificateAverage,
  1083.             "dateRelease" => $this->getDateRelease(),
  1084.             "dateUpdate" => $this->getDateUpdate(),
  1085.             "photo" => FileService::getFilePathComplete(
  1086.                 $this->photoCourseEnum::PATH_STORE
  1087.                 true
  1088.                 true
  1089.             ),
  1090.             "cover" => FileService::getFilePathComplete(
  1091.                 $this->cover
  1092.                 CourseEnum::PATH_COVERS
  1093.                 true
  1094.                 true
  1095.             ),
  1096.             "support" => $this->support,
  1097.             "supportPeriod" => $this->supportPeriod,
  1098.             "lifetimeSupport" => $this->lifetimeSupport,
  1099.             "workload" => $this->workload,
  1100.             "status" => $this->status,
  1101.             "free" => $this->free,
  1102.             "accessPeriod" => $this->accessPeriod,
  1103.             "lifetimePeriod" => $this->lifetimePeriod,
  1104.             "numberLesson" => $this->numberLesson,
  1105.             "controlLessonRequirement" => $this->controlLessonRequirement,
  1106.             "controlLessonReleaseType" => $this->controlLessonReleaseType,
  1107.             "controlLessonAfterType" => $this->controlLessonAfterType,
  1108.             "controlLessonDateRelease" => $this->getControlLessonDateRelease(),
  1109.             "controlLessonReleasePeriod" => $this->controlLessonReleasePeriod,
  1110.             "controlLessonClosePeriod" => $this->controlLessonClosePeriod,
  1111.             "controlLessonTime" => $this->controlLessonTime,
  1112.             "controlLessonTimeStay" => $this->getControlLessonTimeStay(),
  1113.             "controlLessonViewLimit" => $this->controlLessonViewLimit,
  1114.             "controlLessonViewNumber" => $this->controlLessonViewNumber,
  1115.             "controlLessonShowDocument" => $this->controlLessonShowDocument,
  1116.             "controlLessonApply" => $this->controlLessonApply,
  1117.             "courseCertificateTemplate" => ( 
  1118.                 $this->courseCertificateTemplate 
  1119.                 $this->courseCertificateTemplate->getId() : 
  1120.                 null
  1121.             ),
  1122.             "configPeriodMinConclusion" => $this->configPeriodMinConclusion,
  1123.             "certificatePeriod" => $this->certificatePeriod,
  1124.             "courseCategory" => ( $this->category $this->category->getId() : null ),
  1125.             "user" => ( $this->user $this->user->getId() : null ),
  1126.             "userName" => ( $this->user $this->user->getName() : null ),
  1127.             "userPhoto" => (
  1128.                 $this->user 
  1129.                     FileService::getFilePathComplete(
  1130.                         $this->user->getPhoto(), 
  1131.                         CourseEnum::PATH_PROFILES
  1132.                         true
  1133.                         true
  1134.                     )
  1135.                 : null 
  1136.             ),
  1137.             "userUsername" => ( $this->user $this->user->getUsername() : null ),
  1138.             "group" => $arrGroup,
  1139.             "product" => $arrProduct,
  1140.             "cart" => $arrCart,
  1141.             "userDelete" => ( $this->userDelete $this->userDelete->getId() : null ),
  1142.             "typeDelete" => $this->typeDelete,
  1143.             "dateDelete" => $this->getDateDelete()
  1144.         ];
  1145.         return $data;
  1146.     }
  1147.     public function toReturnApi(){
  1148.         $data = [
  1149.             "id" => $this->id,
  1150.             "ordem_curso" => $this->order,
  1151.             "curso_titulo" => $this->getTitle(),
  1152.             "emitir_certificado" => $this->certificate,
  1153.             "media_emitir" => $this->certificateAverage,
  1154.             "data_lancamento" => $this->getDateRelease(),
  1155.             "data_atualizacao" => $this->getDateUpdate(),
  1156.             "foto" => FileService::getFilePathComplete(
  1157.                 $this->photoCourseEnum::PATH_STORE
  1158.                 true
  1159.                 true
  1160.             ),
  1161.             "cover" => FileService::getFilePathComplete(
  1162.                 $this->cover
  1163.                 CourseEnum::PATH_COVERS
  1164.                 true
  1165.                 true
  1166.             ),
  1167.             "suporte" => $this->support,
  1168.             "suporte_vitalicio" => $this->lifetimeSupport,
  1169.             "carga_horaria" => $this->workload,
  1170.             "status" => $this->status,
  1171.             "liberado" => $this->free,
  1172.             "periodo_acesso" => $this->accessPeriod,
  1173.             "vitalicio" => $this->lifetimePeriod,
  1174.             "acesso_vitalicio" => $this->lifetimePeriod,
  1175.             "certificado_template_id" => ( 
  1176.                 $this->courseCertificateTemplate 
  1177.                 $this->courseCertificateTemplate->getId() : 
  1178.                 null 
  1179.             ),
  1180.             "categoria_id" => ( $this->category $this->category->getId() : null ),
  1181.             "professor_id" => ( $this->user $this->user->getId() : null ),
  1182.             "nome_professor" => ( $this->user $this->user->getName() : null ),
  1183.             "foto_professor" => (
  1184.                 $this->user 
  1185.                     FileService::getFilePathComplete(
  1186.                         $this->user->getPhoto(), 
  1187.                         CourseEnum::PATH_PROFILES
  1188.                         true
  1189.                         true
  1190.                     )
  1191.                 : null 
  1192.             ),
  1193.         ];
  1194.         return $data;
  1195.     }
  1196. }