src/Entity/Nuptials.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NuptialsRepository;
  4. use DateTime;
  5. use DateTimeImmutable;
  6. use DateTimeInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. #[ORM\Entity(repositoryClassNuptialsRepository::class)]
  14. #[Vich\Uploadable]
  15. class Nuptials
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     private $id;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.     private $titolo;
  23.     /**
  24.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  25.      */
  26.     #[Vich\UploadableField(mapping'nuptials'fileNameProperty'copertina')]
  27.     private ?File $imageFile null;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private $copertina;
  30.     #[ORM\Column(type'text'nullabletrue)]
  31.     private $descrizione;
  32.     #[ORM\OneToMany(mappedBy'nuptial'targetEntityNuptialsGallery::class, orphanRemovaltrue)]
  33.     private $nuptialsGalleries;
  34.     #[ORM\Column(type'datetime')]
  35.     private $updatedAt;
  36.     public function __construct()
  37.     {
  38.         $this->updatedAt = new DateTime('now');
  39.         $this->nuptialsGalleries = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getTitolo(): ?string
  46.     {
  47.         return $this->titolo;
  48.     }
  49.     public function setTitolo(?string $titolo): self
  50.     {
  51.         $this->titolo $titolo;
  52.         return $this;
  53.     }
  54.     /**
  55.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  56.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  57.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  58.      * must be able to accept an instance of 'File' as the bundle will inject one here
  59.      * during Doctrine hydration.
  60.      *
  61.      * @param File|UploadedFile|null $imageFile
  62.      */
  63.     public function setImageFile(?File $imageFile null): void
  64.     {
  65.         $this->imageFile $imageFile;
  66.         if (null !== $imageFile) {
  67.             // It is required that at least one field changes if you are using doctrine
  68.             // otherwise the event listeners won't be called and the file is lost
  69.             $this->updatedAt = new DateTimeImmutable();
  70.         }
  71.     }
  72.     public function getImageFile(): ?File
  73.     {
  74.         return $this->imageFile;
  75.     }
  76.     public function getCopertina(): ?string
  77.     {
  78.         return $this->copertina;
  79.     }
  80.     public function setCopertina(?string $copertina): self
  81.     {
  82.         $this->copertina $copertina;
  83.         return $this;
  84.     }
  85.     public function getDescrizione(): ?string
  86.     {
  87.         return $this->descrizione;
  88.     }
  89.     public function setDescrizione(?string $descrizione): self
  90.     {
  91.         $this->descrizione $descrizione;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return Collection<int, NuptialsGallery>
  96.      */
  97.     public function getNuptialsGalleries(): Collection
  98.     {
  99.         return $this->nuptialsGalleries;
  100.     }
  101.     public function addNuptialsGallery(NuptialsGallery $nuptialsGallery): self
  102.     {
  103.         if (!$this->nuptialsGalleries->contains($nuptialsGallery)) {
  104.             $this->nuptialsGalleries[] = $nuptialsGallery;
  105.             $nuptialsGallery->setNuptial($this);
  106.         }
  107.         return $this;
  108.     }
  109.     public function removeNuptialsGallery(NuptialsGallery $nuptialsGallery): self
  110.     {
  111.         if ($this->nuptialsGalleries->removeElement($nuptialsGallery)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($nuptialsGallery->getNuptial() === $this) {
  114.                 $nuptialsGallery->setNuptial(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119.     public function getUpdatedAt(): ?DateTimeInterface
  120.     {
  121.         return $this->updatedAt;
  122.     }
  123.     public function setUpdatedAt(DateTimeInterface $updatedAt): self
  124.     {
  125.         $this->updatedAt $updatedAt;
  126.         return $this;
  127.     }
  128.     public function __toString(): string
  129.     {
  130.         return $this->titolo;
  131.     }
  132. }