<?php
namespace App\Entity;
use App\Repository\GalerieRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: GalerieRepository::class)]
#[Vich\Uploadable]
class Galerie
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $titre = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[ORM\Column(type: Types::TEXT, length:10000)]
private ?string $description = null;
// #[ORM\Column(type:'string', length:255)]
// private $image;
// #[Vich\UploadableField(mapping:'post_thumbnails', fileNameProperty:'image')]
// private $imageFile;
#[ORM\OneToMany(mappedBy: 'galerie', targetEntity: Image::class, cascade: ['persist', 'remove'])]
private $images;
#[ORM\OneToMany(mappedBy: 'galerie', targetEntity: Video::class, cascade: ['persist', 'remove'])]
private $videos;
public function __construct()
{
$this->images = new ArrayCollection();
$this->videos = new ArrayCollection();
}
// #[ORM\Column(type:'datetime')]
// private $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
// public function setImageFile(File $image = null)
// {
// $this->imageFile = $image;
// // VERY IMPORTANT:
// // It is required that at least one field changes if you are using Doctrine,
// // otherwise the event listeners won't be called and the file is lost
// // if ($image) {
// // if 'updatedAt' is not defined in your entity, use another property
// // $this->updatedAt = new \DateTime('now');
// // }
// }
// public function getImageFile()
// {
// return $this->imageFile;
// }
// public function setImage($image)
// {
// $this->image = $image;
// }
// public function getImage()
// {
// return $this->image;
// }
/**
* @return Collection<int, Image>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(Image $image): ?self
{
if (!$this->images->contains($image)) {
$this->images->add($image);
$image->setGalerie($this);
}
return $this;
}
public function removeImage(Image $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getGalerie() === $this) {
$image->setGalerie(null);
}
}
return $this;
}
////
/**
* @return Collection<int, Video>
*/
public function getVideos(): Collection
{
return $this->videos;
}
public function addVideo(?Video $video): self
{
if (!$this->images->contains($video)) {
$this->images->add($video);
$video->setGalerie($this);
}
return $this;
}
public function removeVideo(?Video $video): self
{
if ($this->images->removeElement($video)) {
// set the owning side to null (unless already changed)
if ($video->getGalerie() === $this) {
$video->setGalerie(null);
}
}
return $this;
}
public function __toString()
{
return (string) $this->id;
}
}