src/Entity/Cours.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CoursRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CoursRepository::class)
  9.  * @Vich\Uploadable
  10.  */
  11. class Cours
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="cours")
  21.      */
  22.     private $author;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $title;
  27.     /**
  28.      * @ORM\Column(type="text", nullable=true)
  29.      */
  30.     private $body;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $image;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $videoLink;
  39.     /**
  40.      * @ORM\Column(type="datetime_immutable")
  41.      */
  42.     private $createdAt;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $published;
  47.     /**
  48.      * @Vich\UploadableField(mapping="cours_images", fileNameProperty="image")
  49.      * @var File
  50.      */
  51.     private $imageFile;
  52.     /**
  53.      * @Vich\UploadableField(mapping="cours_videos", fileNameProperty="videoLink")
  54.      * @var File
  55.      */
  56.     private $imageFile2;
  57.     /**
  58.      * @Vich\UploadableField(mapping="cours_attachments", fileNameProperty="pdfLink")
  59.      * @var File
  60.      */
  61.     private $imageFile3;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      */
  65.     private $updatedAt;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=CourseCategory::class, inversedBy="cours")
  68.      */
  69.     private $category;
  70.     /**
  71.      * @ORM\Column(type="string", length=255, nullable=true)
  72.      */
  73.     private $pdfLink;
  74.     public function __construct()
  75.     {
  76.         $this->published true;
  77.         $this->createdAt = new \DateTimeImmutable();
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getAuthor(): ?User
  84.     {
  85.         return $this->author;
  86.     }
  87.     public function setAuthor(?User $author): self
  88.     {
  89.         $this->author $author;
  90.         return $this;
  91.     }
  92.     public function getTitle(): ?string
  93.     {
  94.         return $this->title;
  95.     }
  96.     public function setTitle(string $title): self
  97.     {
  98.         $this->title $title;
  99.         return $this;
  100.     }
  101.     public function getBody(): ?string
  102.     {
  103.         return $this->body;
  104.     }
  105.     public function setBody(string $body): self
  106.     {
  107.         $this->body $body;
  108.         return $this;
  109.     }
  110.     public function getImage(): ?string
  111.     {
  112.         return $this->image;
  113.     }
  114.     public function setImage(?string $image): self
  115.     {
  116.         $this->image $image;
  117.         return $this;
  118.     }
  119.     public function getVideoLink(): ?string
  120.     {
  121.         return $this->videoLink;
  122.     }
  123.     public function setVideoLink(?string $videoLink): self
  124.     {
  125.         $this->videoLink $videoLink;
  126.         return $this;
  127.     }
  128.     public function getCreatedAt(): ?\DateTimeImmutable
  129.     {
  130.         return $this->createdAt;
  131.     }
  132.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  133.     {
  134.         $this->createdAt $createdAt;
  135.         return $this;
  136.     }
  137.     public function isPublished(): ?bool
  138.     {
  139.         return $this->published;
  140.     }
  141.     public function setPublished(bool $published): self
  142.     {
  143.         $this->published $published;
  144.         return $this;
  145.     }
  146.     public function setImageFile(File $image null)
  147.     {
  148.         $this->imageFile $image;
  149.         // VERY IMPORTANT:
  150.         // It is required that at least one field changes if you are using Doctrine,
  151.         // otherwise the event listeners won't be called and the file is lost
  152.         if ($image) {
  153.             // if 'updatedAt' is not defined in your entity, use another property
  154.             $this->updatedAt = new \DateTime('now');
  155.         }
  156.     }
  157.     public function getImageFile()
  158.     {
  159.         return $this->imageFile;
  160.     }
  161.     public function setImageFile2(File $image null)
  162.     {
  163.         $this->imageFile2 $image;
  164.         // VERY IMPORTANT:
  165.         // It is required that at least one field changes if you are using Doctrine,
  166.         // otherwise the event listeners won't be called and the file is lost
  167.         if ($image) {
  168.             // if 'updatedAt' is not defined in your entity, use another property
  169.             $this->updatedAt = new \DateTime('now');
  170.         }
  171.     }
  172.     public function getImageFile2()
  173.     {
  174.         return $this->imageFile2;
  175.     }
  176.     public function setImageFile3(File $image null)
  177.     {
  178.         $this->imageFile3 $image;
  179.         // VERY IMPORTANT:
  180.         // It is required that at least one field changes if you are using Doctrine,
  181.         // otherwise the event listeners won't be called and the file is lost
  182.         if ($image) {
  183.             // if 'updatedAt' is not defined in your entity, use another property
  184.             $this->updatedAt = new \DateTime('now');
  185.         }
  186.     }
  187.     public function getImageFile3()
  188.     {
  189.         return $this->imageFile3;
  190.     }
  191.     public function getUpdatedAt(): ?\DateTimeInterface
  192.     {
  193.         return $this->updatedAt;
  194.     }
  195.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  196.     {
  197.         $this->updatedAt $updatedAt;
  198.         return $this;
  199.     }
  200.     public function getLastUpdatedAt(): \DateTimeInterface
  201.     {
  202.         if (null != $this->updatedAt) {
  203.             return $this->updatedAt;
  204.         }
  205.         return $this->createdAt;
  206.     }
  207.     public function togglePublish(): void
  208.     {
  209.         $this->published = !$this->published;
  210.     }
  211.     public function getCategory(): ?CourseCategory
  212.     {
  213.         return $this->category;
  214.     }
  215.     public function setCategory(?CourseCategory $category): self
  216.     {
  217.         $this->category $category;
  218.         return $this;
  219.     }
  220.     public function getPdfLink(): ?string
  221.     {
  222.         return $this->pdfLink;
  223.     }
  224.     public function setPdfLink(?string $pdfLink): self
  225.     {
  226.         $this->pdfLink $pdfLink;
  227.         return $this;
  228.     }
  229.     public function isPdf(): bool
  230.     {
  231.         return null != $this->pdfLink;
  232.     }
  233.     public function isDownloadable() :bool
  234.     {
  235.         return null != $this->videoLink || null != $this->pdfLink;
  236.     }
  237. }