src/Entity/Quote/QuoteRequestFile.php line 16

  1. <?php
  2. namespace App\Entity\Quote;
  3. use App\Repository\Quote\QuoteRequestFileRepository;
  4. use Doctrine\DBAL\Types\Types;
  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(repositoryClass: QuoteRequestFileRepository::class)]
  9. #[ORM\Table(name: 'app_quote_request_file')]
  10. #[Vich\Uploadable]
  11. class QuoteRequestFile
  12. { 
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id = null; 
  17.     #[ORM\ManyToOne(inversedBy: 'files')]
  18.     private ?QuoteRequest $quote = null;
  19.     #[ORM\ManyToOne]
  20.     private ?RequestFileType $type = null;
  21.     #[ORM\Column(length: 255, nullable: true)]
  22.     private ?string $path = null;
  23.     private ?string $url = null;
  24.     #[ORM\Column(nullable: true)]
  25.     private ?int $size = null;
  26.     #[ORM\Column(length: 50)]
  27.     private ?string $mimeType = null;
  28.     #[ORM\Column(length: 255)]
  29.     private ?string $originalName = null;
  30.     #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
  31.     private ?\DateTimeInterface $updatedAt = null;
  32.     #[ORM\Column(type: Types::ARRAY, nullable: true)]
  33.     private ?array $dimensions = [];
  34.     // NOTE: This is not a mapped field of entity metadata, just a simple property.
  35.     #[Vich\UploadableField(mapping: 'quote_request_file', fileNameProperty: 'path', size: 'size', dimensions: 'dimensions', mimeType: 'mimeType', originalName: 'originalName')]
  36.     private ?File $file = null;
  37.     /**
  38.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  39.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  40.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  41.      * must be able to accept an instance of 'File' as the bundle will inject one here
  42.      * during Doctrine hydration.
  43.      *
  44.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  45.      */
  46.     public function setFile(?File $file = null): void
  47.     {
  48.         $this->file = $file;
  49.         if (null !== $file) {
  50.             // It is required that at least one field changes if you are using doctrine
  51.             // otherwise the event listeners won't be called and the file is lost
  52.             $this->updatedAt = new \DateTimeImmutable();
  53.         }
  54.     }
  55.     public function getFile(): ?File
  56.     {
  57.         return $this->file;
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     } 
  63.     public function getPath(): ?string
  64.     {
  65.         return $this->path;
  66.     }
  67.     public function setPath(?string $path): self
  68.     {
  69.         $this->path = $path;
  70.         return $this;
  71.     }
  72.     public function getUrl(): ?string
  73.     {
  74.         return $this->url;
  75.     }
  76.     public function setUrl(string $url): self
  77.     {
  78.         $this->url = $url;
  79.         return $this;
  80.     }
  81.     public function getSize(): ?int
  82.     {
  83.         return $this->size;
  84.     }
  85.     public function setSize(?int $size): self
  86.     {
  87.         $this->size = $size;
  88.         return $this;
  89.     }
  90.     public function getMimeType(): ?string
  91.     {
  92.         return $this->mimeType;
  93.     }
  94.     public function setMimeType(string $mimeType): self
  95.     {
  96.         $this->mimeType = $mimeType;
  97.         return $this;
  98.     }
  99.     public function getOriginalName(): ?string
  100.     {
  101.         return $this->originalName;
  102.     }
  103.     public function setOriginalName(string $originalName): self
  104.     {
  105.         $this->originalName = $originalName;
  106.         return $this;
  107.     }
  108.     public function getUpdatedAt(): ?\DateTimeInterface
  109.     {
  110.         return $this->updatedAt;
  111.     }
  112.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  113.     {
  114.         $this->updatedAt = $updatedAt;
  115.         return $this;
  116.     }
  117.     public function getDimensions(): array
  118.     {
  119.         return $this->dimensions;
  120.     }
  121.     public function setDimensions(?array $dimensions): self
  122.     {
  123.         $this->dimensions = $dimensions;
  124.         return $this;
  125.     }
  126.     public function getQuote(): ?QuoteRequest
  127.     {
  128.         return $this->quote;
  129.     }
  130.     public function setQuote(?QuoteRequest $quote): self
  131.     {
  132.         $this->quote = $quote;
  133.         return $this;
  134.     }
  135.     public function getType(): ?RequestFileType
  136.     {
  137.         return $this->type;
  138.     }
  139.     public function setType(?RequestFileType $type): self
  140.     {
  141.         $this->type = $type;
  142.         return $this;
  143.     }
  144. }