src/Entity/InspectionImages.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InspectionImagesRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8.  * @ORM\Entity(repositoryClass=InspectionImagesRepository::class)
  9.  * @ORM\HasLifecycleCallbacks()
  10.  * @Vich\Uploadable
  11.  */
  12. class InspectionImages
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  22.      *
  23.      * @Vich\UploadableField(mapping="inspection_image", fileNameProperty="image")
  24.      *
  25.      * @var File|null
  26.      */
  27.     private $imageFile;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $image;
  32.     /**
  33.      * @ORM\Column(type="boolean", nullable=true)
  34.      */
  35.     private $isMain;
  36.     /**
  37.      * @ORM\Column(type="datetime")
  38.      */
  39.     private $createdAt;
  40.     /**
  41.      * @ORM\Column(type="datetime", nullable=true)
  42.      */
  43.     private $updatedAt;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity=Inspection::class, inversedBy="imageId")
  46.      * @ORM\JoinColumn(nullable=false)
  47.      */
  48.     private $car;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     /**
  54.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  55.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  56.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  57.      * must be able to accept an instance of 'File' as the bundle will inject one here
  58.      * during Doctrine hydration.
  59.      *
  60.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  61.      */
  62.     public function setImageFile(?File $imageFile null): void
  63.     {
  64.         $this->imageFile $imageFile;
  65.         if (null !== $imageFile) {
  66.             // It is required that at least one field changes if you are using doctrine
  67.             // otherwise the event listeners won't be called and the file is lost
  68.             $this->updatedAt = new \DateTime();
  69.         }
  70.     }
  71.     public function getImageFile(): ?File
  72.     {
  73.         return $this->imageFile;
  74.     }
  75.     public function getImage(): ?string
  76.     {
  77.         return $this->image;
  78.     }
  79.     public function setImage(?string $image): self
  80.     {
  81.         $this->image $image;
  82.         return $this;
  83.     }
  84.     public function getIsMain(): ?bool
  85.     {
  86.         return $this->isMain;
  87.     }
  88.     public function setIsMain(bool $isMain): self
  89.     {
  90.         $this->isMain $isMain;
  91.         return $this;
  92.     }
  93.     public function getCreatedAt(): ?\DateTimeInterface
  94.     {
  95.         return $this->createdAt;
  96.     }
  97.     /**
  98.      * @ORM\PrePersist
  99.      */
  100.     public function setCreatedAt(): self
  101.     {
  102.         $this->createdAt = new \DateTime();
  103.         return $this;
  104.     }
  105.     public function getUpdatedAt(): ?\DateTimeInterface
  106.     {
  107.         return $this->updatedAt;
  108.     }
  109.     /**
  110.      * @ORM\PreUpdate
  111.      */
  112.     public function setUpdatedAt(): self
  113.     {
  114.         $this->updatedAt = new \DateTime();
  115.         return $this;
  116.     }
  117.     public function getCar(): ?Inspection
  118.     {
  119.         return $this->car;
  120.     }
  121.     public function setCar(?Inspection $car): self
  122.     {
  123.         $this->car $car;
  124.         return $this;
  125.     }
  126.     public function __toString()
  127.     {
  128.         return $this->image;
  129.     }
  130. }