src/Entity/Weather.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WeatherRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. use Symfony\Component\Serializer\Annotation\Ignore;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. /**
  15.  * @ORM\Entity(repositoryClass=WeatherRepository::class)
  16.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  17.  * @Vich\Uploadable
  18.  */
  19. class Weather
  20. {
  21.     use TimestampableEntity;
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      * @Groups("weather:list", "weather:item")
  27.      */
  28.     private $id;
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     /**
  34.      * @Assert\File(
  35.      *     mimeTypes = {"application/pdf", "application/x-pdf"},
  36.      *     mimeTypesMessage = "Please upload a valid PDF"
  37.      * )
  38.      * @Vich\UploadableField(mapping="weather", fileNameProperty="pdfName", size="pdfSize")
  39.      * @var File|null
  40.      *  @Ignore()
  41.      */
  42.     private $pdfFile;
  43.     /**
  44.      * @param File|UploadedFile|null $pdfFile
  45.      */
  46.     public function setPdfFile(?File $pdfFile null): void
  47.     {
  48.         $this->pdfFile $pdfFile;
  49.         if (null !== $pdfFile) {
  50.             $this->updatedAt = new \DateTimeImmutable();
  51.         }
  52.     }
  53.     public function getPdfFile(): ?File
  54.     {
  55.         return $this->pdfFile;
  56.     }
  57.     /**
  58.      * @ORM\Column(type="string")
  59.      *
  60.      * @var string|null
  61.      * @Groups("weather:list", "weather:item")
  62.      */
  63.     private $pdfName;
  64.     /**
  65.      * @ORM\Column(type="integer")
  66.      *
  67.      * @var int|null
  68.      */
  69.     private $pdfSize;
  70.     /**
  71.      * @ORM\Column(type="datetime", nullable=true)
  72.      * @var \DateTime|null
  73.      */
  74.     protected $deletedAt;
  75.     /**
  76.      * Set or clear the deleted at timestamp.
  77.      *
  78.      * @return self
  79.      */
  80.     public function setDeletedAt(\DateTime $deletedAt null)
  81.     {
  82.         $this->deletedAt $deletedAt;
  83.         return $this;
  84.     }
  85.     /**
  86.      * Get the deleted at timestamp value. Will return null if
  87.      * the entity has not been soft deleted.
  88.      *
  89.      * @return \DateTime|null
  90.      */
  91.     public function getDeletedAt()
  92.     {
  93.         return $this->deletedAt;
  94.     }
  95.     public function setPdfName(?string $pdfName): void
  96.     {
  97.         $this->pdfName $pdfName;
  98.     }
  99.     public function getPdfName(): ?string
  100.     {
  101.         return $this->pdfName;
  102.     }
  103.     public function setPdfSize(?int $pdfSize): void
  104.     {
  105.         $this->pdfSize $pdfSize;
  106.     }
  107.     public function getPdfSize(): ?int
  108.     {
  109.         return $this->pdfSize;
  110.     }
  111. }