src/Entity/PhotoGalery.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PhotoGaleryRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. #[ORM\Entity(repositoryClassPhotoGaleryRepository::class)]
  11. #[Vich\Uploadable]
  12. class PhotoGalery
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $title null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $filename null;
  22.     #[Vich\UploadableField(mapping"photoGalery"fileNameProperty"filename")]
  23.     #[Assert\Image(
  24.         mimeTypes: ['image/jpeg''image/png''image/jpg''image/gif'],
  25.         mimeTypesMessage"Les formats d'images acceptés sont : .jpeg .png .jpg and .gif"
  26.     )]
  27.     private ?File $imageFile null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  29.     private ?\DateTimeInterface $createdAt null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  31.     private ?\DateTimeInterface $updatedAt null;
  32.     #[ORM\ManyToOne(inversedBy'photoGaleries')]
  33.     private ?AlbumPhoto $album null;
  34.     public function __construct()
  35.     {
  36.         $this->createdAt = new \DateTime('now');
  37.         $this->updatedAt = new \DateTime('now');
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getTitle(): ?string
  44.     {
  45.         return $this->title;
  46.     }
  47.     public function setTitle(string $title): static
  48.     {
  49.         $this->title $title;
  50.         return $this;
  51.     }
  52.     public function getFilename(): ?string
  53.     {
  54.         return $this->filename;
  55.     }
  56.     public function setFilename(?string $filename): static
  57.     {
  58.         $this->filename $filename;
  59.         return $this;
  60.     }
  61.     /**
  62.      * @return null|File
  63.      */
  64.     public function getImageFile(): ?File
  65.     {
  66.         return $this->imageFile;
  67.     }
  68.     /**
  69.      * @param null|File $imageFile
  70.      * @return PhotoGalery
  71.      */
  72.     public function setImageFile(?File $imageFile): self
  73.     {
  74.         $this->imageFile $imageFile;
  75.         if ($this->imageFile instanceof UploadedFile) {
  76.             $this->updatedAt = new \DateTime('now');
  77.         }
  78.         return $this;
  79.     }
  80.     public function getCreatedAt(): ?\DateTimeInterface
  81.     {
  82.         return $this->createdAt;
  83.     }
  84.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  85.     {
  86.         $this->createdAt $createdAt;
  87.         return $this;
  88.     }
  89.     public function getUpdatedAt(): ?\DateTimeInterface
  90.     {
  91.         return $this->updatedAt;
  92.     }
  93.     public function setUpdatedAt(\DateTimeInterface $updatedAt): static
  94.     {
  95.         $this->updatedAt $updatedAt;
  96.         return $this;
  97.     }
  98.     public function getAlbum(): ?AlbumPhoto
  99.     {
  100.         return $this->album;
  101.     }
  102.     public function setAlbum(?AlbumPhoto $album): static
  103.     {
  104.         $this->album $album;
  105.         return $this;
  106.     }
  107. }