src/Entity/Images.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\ImagesRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Doctrine\DBAL\Types\Types;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassImagesRepository::class)]
  11. #[ApiResource]
  12. #[Vich\Uploadable]
  13. class Images
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $path null;
  21.     #[Vich\UploadableField(mapping'event'fileNameProperty'path')]
  22.     #[Assert\Image(
  23.         maxSize'10240k',
  24.         mimeTypes: ['image/*'],
  25.         mimeTypesMessage"Veuillez donner une image"
  26.     )]
  27.     private  $file null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  29.     private ?\DateTimeInterface $updatedAt null;
  30.     #[ORM\ManyToOne(inversedBy'images')]
  31.     private ?Evenement $evenement null;
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getPath(): ?string
  37.     {
  38.         return $this->path;
  39.     }
  40.     public function setPath(?string $path): self
  41.     {
  42.         $this->path $path;
  43.         return $this;
  44.     }
  45.     public function setFile(File $file null)
  46.     {
  47.         $this->file $file;
  48.         if (null !== $file) {
  49.             $this->updatedAt = new \Datetime();
  50.         }
  51.     }
  52.     public function getFile()
  53.     {
  54.         return $this->file;
  55.     }
  56.     
  57.     public function getUpdatedAt(): ?\DateTimeInterface
  58.     {
  59.         return $this->updatedAt;
  60.     }
  61.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  62.     {
  63.         $this->updatedAt $updatedAt;
  64.         return $this;
  65.     }
  66.     public function getEvenement(): ?Evenement
  67.     {
  68.         return $this->evenement;
  69.     }
  70.     public function setEvenement(?Evenement $evenement): self
  71.     {
  72.         $this->evenement $evenement;
  73.         return $this;
  74.     }
  75. }