src/Entity/Attachment.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AttachmentRepository;
  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=AttachmentRepository::class)
  9.  * @Vich\Uploadable
  10.  */
  11. class Attachment
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $url;
  27.     /**
  28.      * @ORM\Column(type="datetime", nullable=true)
  29.      */
  30.     private $updatedAt;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Cours::class)
  33.      */
  34.     private $course;
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private $createdAt;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $inabled;
  43.      /**
  44.      * @Vich\UploadableField(mapping="cours_attachments", fileNameProperty="url")
  45.      * @var File
  46.      */
  47.     private $imageFile;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.         $this->inabled true;
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(string $name): self
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getUrl(): ?string
  67.     {
  68.         return $this->url;
  69.     }
  70.     public function setUrl(?string $url): self
  71.     {
  72.         $this->url $url;
  73.         return $this;
  74.     }
  75.     public function getUpdatedAt(): ?\DateTimeInterface
  76.     {
  77.         return $this->updatedAt;
  78.     }
  79.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  80.     {
  81.         $this->updatedAt $updatedAt;
  82.         return $this;
  83.     }
  84.     public function getCourse(): ?Cours
  85.     {
  86.         return $this->course;
  87.     }
  88.     public function setCourse(?Cours $course): self
  89.     {
  90.         $this->course $course;
  91.         return $this;
  92.     }
  93.     public function getCreatedAt(): ?\DateTimeInterface
  94.     {
  95.         return $this->createdAt;
  96.     }
  97.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  98.     {
  99.         $this->createdAt $createdAt;
  100.         return $this;
  101.     }
  102.     public function isInabled(): ?bool
  103.     {
  104.         return $this->inabled;
  105.     }
  106.     public function setInabled(bool $inabled): self
  107.     {
  108.         $this->inabled $inabled;
  109.         return $this;
  110.     }
  111.     public function setImageFile(File $image null)
  112.     {
  113.         $this->imageFile $image;
  114.         // VERY IMPORTANT:
  115.         // It is required that at least one field changes if you are using Doctrine,
  116.         // otherwise the event listeners won't be called and the file is lost
  117.         if ($image) {
  118.             // if 'updatedAt' is not defined in your entity, use another property
  119.             $this->updatedAt = new \DateTime('now');
  120.         }
  121.     }
  122.     public function getImageFile()
  123.     {
  124.         return $this->imageFile;
  125.     }
  126. }