src/Entity/BookingEventFile.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BookingEventFileRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. #[ORM\Entity(repositoryClassBookingEventFileRepository::class)]
  8. #[Vich\Uploadable]
  9. class BookingEventFile
  10. {
  11.     use IdentifiableTrait;
  12.     #[ORM\ManyToOne(targetEntityBookingEvent::class, inversedBy'files')]
  13.     private ?BookingEvent $bookingEvent;
  14.     #[ORM\Column(type'string'nullabletrue)]
  15.     private ?string $fileName null;
  16.     #[Vich\UploadableField(mapping'booking_event_files'fileNameProperty'fileName')]
  17.     private ?File $file null;
  18.     #[ORM\Column(length50nullabletrue)]
  19.     private ?string $name null;
  20.     #[ORM\Column]
  21.     private ?\DateTimeImmutable $updatedAt null;
  22.     // Getters and setters
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function setBookingEvent(?BookingEvent $bookingEvent): self
  28.     {
  29.         $this->bookingEvent $bookingEvent;
  30.         return $this;
  31.     }
  32.     public function getBookingEvent(): ?BookingEvent
  33.     {
  34.         return $this->bookingEvent;
  35.     }
  36.     public function getFileName(): ?string
  37.     {
  38.         return $this->fileName;
  39.     }
  40.     public function setFileName(?string $fileName): void
  41.     {
  42.         $this->fileName $fileName;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): static
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getUpdatedAt(): ?\DateTimeImmutable
  54.     {
  55.         return $this->updatedAt;
  56.     }
  57.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
  58.     {
  59.         $this->updatedAt $updatedAt;
  60.         return $this;
  61.     }
  62.     public function setFile(?File $file null): void
  63.     {
  64.         $this->file $file;
  65.         if (null !== $file) {
  66.             // Il est nécessaire de mettre à jour l'entité pour que Doctrine écoute les changements
  67.             $this->updatedAt = new \DateTimeImmutable();
  68.         }
  69.     }
  70.     public function getFile(): ?File
  71.     {
  72.         return $this->file;
  73.     }
  74. }