<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @Vich\Uploadable
*/
#[ORM\Entity(repositoryClass: \App\Repository\ImagesRepository::class)]
class Images implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $filename= null;
/**
* @Vich\UploadableField(mapping="images", fileNameProperty="filename")
*/
private ?\Symfony\Component\HttpFoundation\File\File $file = null;
#[ORM\Column(type: 'datetime', nullable: true)]
private mixed $date_created;
#[ORM\Column(type: 'datetime', nullable: true)]
private mixed $date_updated;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $alt= null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $credit= null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $title= null;
#[ORM\ManyToMany(targetEntity: PageAccueil::class, mappedBy: 'images')]
private mixed $pageAccueils;
public function __construct()
{
$this->date_created = new \DateTime();
$this->pageAccueils = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setFile(File $file = null): void
{
$this->file = $file;
if ($file) {
$this->date_updated = new \DateTime('now');
}
}
public function getFile(): mixed
{
return $this->file;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(string $filename = null): mixed
{
$this->filename = $filename;
return $this;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->date_updated;
}
public function setDateUpdated(?\DateTimeInterface $date_updated): self
{
$this->date_updated = $date_updated;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(?\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
public function getAlt(): ?string
{
return $this->alt;
}
public function setAlt(?string $alt): self
{
$this->alt = $alt;
return $this;
}
/**
* @return string
*/
public function __toString(): string
{
return $this->title;
}
public function getCredit(): ?string
{
return $this->credit;
}
public function setCredit(?string $credit): self
{
$this->credit = $credit;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, PageAccueil>
*/
public function getPageAccueils(): Collection
{
return $this->pageAccueils;
}
public function addPageAccueil(PageAccueil $pageAccueil): self
{
if (!$this->pageAccueils->contains($pageAccueil)) {
$this->pageAccueils[] = $pageAccueil;
$pageAccueil->addImage($this);
}
return $this;
}
public function removePageAccueil(PageAccueil $pageAccueil): self
{
if ($this->pageAccueils->removeElement($pageAccueil)) {
$pageAccueil->removeImage($this);
}
return $this;
}
}