src/Entity/VehiclePhoto.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\VehiclePhotoRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. #[ORM\Entity(repositoryClassVehiclePhotoRepository::class)]
  9. #[ORM\Table(name'vehicle_photo')]
  10. /**
  11.  * @Vich\Uploadable
  12.  */
  13. class VehiclePhoto
  14. {
  15.     #[ORM\Column(type"boolean")]
  16.     private bool $isDeleted false;
  17.     #[ORM\Column(name"id"type"integer")]
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue(strategy"AUTO")]
  20.     private ?int $id;
  21.     #[ORM\ManyToOne(targetEntity"App\Entity\Vehicle"inversedBy"vehiclePhotos"cascade: ["persist"])]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private Vehicle $vehicle;
  24.     /**
  25.      * @Vich\UploadableField(mapping="vehiclePhoto", fileNameProperty="vehiclePhotoFileName", size="vehiclePhotoFileSize")
  26.      */
  27.     private File $vehiclePhotoFile;
  28.     #[ORM\Column(type"string"length255nullabletrue)]
  29.     private ?string $vehiclePhotoFileName null;
  30.     #[ORM\Column(type"integer"nullabletrue)]
  31.     private ?int $vehiclePhotoFileSize null;
  32.     #[ORM\Column(type"datetime"nullabletrue)]
  33.     private ?DateTime $vehiclePhotoFileUpdatedAt null;
  34.     public function __toString() {
  35.         return "#" $this->id " - " $this->vehiclePhotoFileName;
  36.     }
  37.     public function getVehiclePhotoFile() {
  38.         return $this->vehiclePhotoFile;
  39.     }
  40.     /**
  41.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  42.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  43.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  44.      * must be able to accept an instance of 'File' as the bundle will inject one here
  45.      * during Doctrine hydration.
  46.      *
  47.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  48.      */
  49.     public function setVehiclePhotoFile(File $image null) {
  50.         $this->vehiclePhotoFile $image;
  51.         if (null !== $image) {
  52. // It is required that at least one field changes if you are using doctrine
  53. // otherwise the event listeners won't be called and the file is lost
  54.             $this->vehiclePhotoFileUpdatedAt = new \DateTime();
  55.         }
  56.     }
  57.     /**
  58.      * Get id
  59.      *
  60.      * @return int
  61.      */
  62.     public function getId() {
  63.         return $this->id;
  64.     }
  65.     /**
  66.      * Get vehiclePhotoFileName
  67.      *
  68.      * @return string
  69.      */
  70.     public function getVehiclePhotoFileName() {
  71.         return $this->vehiclePhotoFileName;
  72.     }
  73.     /**
  74.      * Set vehiclePhotoFileName
  75.      *
  76.      * @param string $vehiclePhotoFileName
  77.      *
  78.      * @return VehiclePhoto
  79.      */
  80.     public function setVehiclePhotoFileName($vehiclePhotoFileName) {
  81.         $this->vehiclePhotoFileName $vehiclePhotoFileName;
  82.         return $this;
  83.     }
  84.     /**
  85.      * Get vehiclePhotoFileSize
  86.      *
  87.      * @return integer
  88.      */
  89.     public function getVehiclePhotoFileSize() {
  90.         return $this->vehiclePhotoFileSize;
  91.     }
  92.     /**
  93.      * Set vehiclePhotoFileSize
  94.      *
  95.      * @param integer $vehiclePhotoFileSize
  96.      *
  97.      * @return VehiclePhoto
  98.      */
  99.     public function setVehiclePhotoFileSize($vehiclePhotoFileSize) {
  100.         $this->vehiclePhotoFileSize $vehiclePhotoFileSize;
  101.         return $this;
  102.     }
  103.     /**
  104.      * Get vehiclePhotoFileUpdatedAt
  105.      *
  106.      * @return \DateTime
  107.      */
  108.     public function getVehiclePhotoFileUpdatedAt() {
  109.         return $this->vehiclePhotoFileUpdatedAt;
  110.     }
  111.     /**
  112.      * Set vehiclePhotoFileUpdatedAt
  113.      *
  114.      * @param \DateTime $vehiclePhotoFileUpdatedAt
  115.      *
  116.      * @return VehiclePhoto
  117.      */
  118.     public function setVehiclePhotoFileUpdatedAt($vehiclePhotoFileUpdatedAt) {
  119.         $this->vehiclePhotoFileUpdatedAt $vehiclePhotoFileUpdatedAt;
  120.         return $this;
  121.     }
  122.     /**
  123.      * Get vehicle
  124.      *
  125.      * @return \App\Entity\Vehicle
  126.      */
  127.     public function getVehicle() {
  128.         return $this->vehicle;
  129.     }
  130.     /**
  131.      * Set vehicle
  132.      *
  133.      * @param \App\Entity\Vehicle $vehicle
  134.      *
  135.      * @return VehiclePhoto
  136.      */
  137.     public function setVehicle(\App\Entity\Vehicle $vehicle) {
  138.         $this->vehicle $vehicle;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Get isDeleted
  143.      *
  144.      * @return boolean
  145.      */
  146.     public function getIsDeleted()
  147.     {
  148.         return $this->isDeleted;
  149.     }
  150.     /**
  151.      * Set isDeleted
  152.      *
  153.      * @param boolean $isDeleted
  154.      *
  155.      * @return VehiclePhoto
  156.      */
  157.     public function setIsDeleted($isDeleted)
  158.     {
  159.         $this->isDeleted $isDeleted;
  160.         return $this;
  161.     }
  162. }