src/Entity/Images.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @Vich\Uploadable
  10.  */
  11. #[ORM\Entity(repositoryClass\App\Repository\ImagesRepository::class)]
  12. class Images implements \Stringable
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private int $id;
  18.     #[ORM\Column(type'string'length255nullabletrue)]
  19.     private ?string $filenamenull;
  20.     /**
  21.      * @Vich\UploadableField(mapping="images", fileNameProperty="filename")
  22.      */
  23.     private ?\Symfony\Component\HttpFoundation\File\File $file null;
  24.     #[ORM\Column(type'datetime'nullabletrue)]
  25.     private mixed $date_created;
  26.     #[ORM\Column(type'datetime'nullabletrue)]
  27.     private mixed $date_updated;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private ?string $altnull;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private ?string $creditnull;
  32.     #[ORM\Column(type'string'length255nullabletrue)]
  33.     private ?string $titlenull;
  34.     #[ORM\ManyToMany(targetEntityPageAccueil::class, mappedBy'images')]
  35.     private mixed $pageAccueils;
  36.     public function __construct()
  37.     {
  38.         $this->date_created = new \DateTime();
  39.         $this->pageAccueils = new ArrayCollection();
  40.     }
  41.     public function getId(): int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function setFile(File $file null): void
  46.     {
  47.         $this->file $file;
  48.         if ($file) {
  49.             $this->date_updated = new \DateTime('now');
  50.         }
  51.     }
  52.     public function getFile(): mixed
  53.     {
  54.         return $this->file;
  55.     }
  56.     public function getFilename(): ?string
  57.     {
  58.         return $this->filename;
  59.     }
  60.     public function setFilename(string $filename null): mixed
  61.     {
  62.         $this->filename $filename;
  63.         return $this;
  64.     }
  65.     public function getDateUpdated(): ?\DateTimeInterface
  66.     {
  67.         return $this->date_updated;
  68.     }
  69.     public function setDateUpdated(?\DateTimeInterface $date_updated): self
  70.     {
  71.         $this->date_updated $date_updated;
  72.         return $this;
  73.     }
  74.     public function getDateCreated(): ?\DateTimeInterface
  75.     {
  76.         return $this->date_created;
  77.     }
  78.     public function setDateCreated(?\DateTimeInterface $date_created): self
  79.     {
  80.         $this->date_created $date_created;
  81.         return $this;
  82.     }
  83.     public function getAlt(): ?string
  84.     {
  85.         return $this->alt;
  86.     }
  87.     public function setAlt(?string $alt): self
  88.     {
  89.         $this->alt $alt;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return string
  94.      */
  95.     public function __toString(): string
  96.     {
  97.         return $this->title;
  98.     }
  99.     public function getCredit(): ?string
  100.     {
  101.         return $this->credit;
  102.     }
  103.     public function setCredit(?string $credit): self
  104.     {
  105.         $this->credit $credit;
  106.         return $this;
  107.     }
  108.     public function getTitle(): ?string
  109.     {
  110.         return $this->title;
  111.     }
  112.     public function setTitle(?string $title): self
  113.     {
  114.         $this->title $title;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection<int, PageAccueil>
  119.      */
  120.     public function getPageAccueils(): Collection
  121.     {
  122.         return $this->pageAccueils;
  123.     }
  124.     public function addPageAccueil(PageAccueil $pageAccueil): self
  125.     {
  126.         if (!$this->pageAccueils->contains($pageAccueil)) {
  127.             $this->pageAccueils[] = $pageAccueil;
  128.             $pageAccueil->addImage($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removePageAccueil(PageAccueil $pageAccueil): self
  133.     {
  134.         if ($this->pageAccueils->removeElement($pageAccueil)) {
  135.             $pageAccueil->removeImage($this);
  136.         }
  137.         return $this;
  138.     }
  139. }