<?php
namespace App\Entity;
use App\Repository\CoursRepository;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\HttpFoundation\File\File;
/**
* @ORM\Entity(repositoryClass=CoursRepository::class)
* @Vich\Uploadable
*/
class Cours
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="cours")
*/
private $author;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $body;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $videoLink;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="boolean")
*/
private $published;
/**
* @Vich\UploadableField(mapping="cours_images", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @Vich\UploadableField(mapping="cours_videos", fileNameProperty="videoLink")
* @var File
*/
private $imageFile2;
/**
* @Vich\UploadableField(mapping="cours_attachments", fileNameProperty="pdfLink")
* @var File
*/
private $imageFile3;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=CourseCategory::class, inversedBy="cours")
*/
private $category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pdfLink;
public function __construct()
{
$this->published = true;
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getBody(): ?string
{
return $this->body;
}
public function setBody(string $body): self
{
$this->body = $body;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getVideoLink(): ?string
{
return $this->videoLink;
}
public function setVideoLink(?string $videoLink): self
{
$this->videoLink = $videoLink;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function isPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): self
{
$this->published = $published;
return $this;
}
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function setImageFile2(File $image = null)
{
$this->imageFile2 = $image;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile2()
{
return $this->imageFile2;
}
public function setImageFile3(File $image = null)
{
$this->imageFile3 = $image;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile3()
{
return $this->imageFile3;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getLastUpdatedAt(): \DateTimeInterface
{
if (null != $this->updatedAt) {
return $this->updatedAt;
}
return $this->createdAt;
}
public function togglePublish(): void
{
$this->published = !$this->published;
}
public function getCategory(): ?CourseCategory
{
return $this->category;
}
public function setCategory(?CourseCategory $category): self
{
$this->category = $category;
return $this;
}
public function getPdfLink(): ?string
{
return $this->pdfLink;
}
public function setPdfLink(?string $pdfLink): self
{
$this->pdfLink = $pdfLink;
return $this;
}
public function isPdf(): bool
{
return null != $this->pdfLink;
}
public function isDownloadable() :bool
{
return null != $this->videoLink || null != $this->pdfLink;
}
}