src/Entity/Attachment.php line 13

  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. /**
  7.  * @ORM\Entity(repositoryClass=AttachmentRepository::class)
  8.  * @Vich\Uploadable()
  9.  */
  10. class Attachment
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $image;
  22.     /**
  23.      * @Vich\UploadableField(mapping="attachments", fileNameProperty="image")
  24.      */
  25.     private $imageFile;
  26.     /**
  27.      * @ORM\Column(type="datetime", nullable=true)
  28.      */
  29.     private $createdAt;
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=true)
  32.      */
  33.     private $updatedAt;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=Project::class, inversedBy="attachments")
  36.      */
  37.     private $project;
  38.     public function __construct() {
  39.         $this->createdAt = new \DateTime;
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getImage(): ?string
  46.     {
  47.         return $this->image;
  48.     }
  49.     public function setImage(?string $image): self
  50.     {
  51.         $this->image $image;
  52.         return $this;
  53.     }
  54.     public function getCreatedAt(): ?\DateTimeInterface
  55.     {
  56.         return $this->createdAt;
  57.     }
  58.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  59.     {
  60.         $this->createdAt $createdAt;
  61.         return $this;
  62.     }
  63.     public function getUpdatedAt(): ?\DateTimeInterface
  64.     {
  65.         return $this->updatedAt;
  66.     }
  67.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  68.     {
  69.         $this->updatedAt $updatedAt;
  70.         return $this;
  71.     }
  72.     public function getProject(): ?Project
  73.     {
  74.         return $this->project;
  75.     }
  76.     public function setProject(?Project $project): self
  77.     {
  78.         $this->project $project;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return mixed
  83.      */
  84.     public function getImageFile()
  85.     {
  86.         return $this->imageFile;
  87.     }
  88.     /**
  89.      * @param mixed $imageFile
  90.      */
  91.     public function setImageFile$imageFile ) : void
  92.     {
  93.         $this->imageFile $imageFile;
  94.         if($imageFile) {
  95.             $this->updatedAt = new \DateTime;
  96.         }
  97.     }
  98. }