<?php
namespace App\Entity;
use App\Repository\EvenementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: EvenementRepository::class)]
#[Vich\Uploadable]
class Evenement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
private ?string $wording = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\NotBlank(message: "Le champ ne peut pas être vide.")]
private ?string $descriptionCourte = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[Vich\UploadableField(mapping: 'event', fileNameProperty: 'image')]
#[Assert\Image(
maxSize: '10240k',
mimeTypes: ['image/*'],
mimeTypesMessage: "Veuillez donner une image"
)]
private $imageFile = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateDebut = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateFin = null;
#[ORM\OneToMany(mappedBy: 'evenement', targetEntity: Images::class,cascade: ["persist"])]
private Collection $images;
#[ORM\Column(length: 255, nullable: true)]
private ?string $video = null;
#[Vich\UploadableField(mapping: 'event', fileNameProperty: 'video')]
private $videoFile = null;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updatedAt = null;
public function __construct()
{
$this->images = new ArrayCollection();
$this->updatedAt = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function setImageFile(File $imageFile = null)
{
$this->imageFile = $imageFile;
if ($imageFile) {
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function getWording(): ?string
{
return $this->wording;
}
public function setWording(?string $wording): self
{
$this->wording = $wording;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getDateDebut(): ?\DateTimeInterface
{
return $this->dateDebut;
}
public function setDateDebut(?\DateTimeInterface $dateDebut): self
{
$this->dateDebut = $dateDebut;
return $this;
}
public function getDateFin(): ?\DateTimeInterface
{
return $this->dateFin;
}
public function setDateFin(?\DateTimeInterface $dateFin): self
{
$this->dateFin = $dateFin;
return $this;
}
/**
* @return Collection<int, Images>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(Images $image): self
{
if (!$this->images->contains($image)) {
$this->images->add($image);
$image->setEvenement($this);
}
return $this;
}
public function removeImage(Images $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getEvenement() === $this) {
$image->setEvenement(null);
}
}
return $this;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setVideo(?string $video): self
{
$this->video = $video;
return $this;
}
public function setVideoFile(File $videoFile = null)
{
$this->videoFile = $videoFile;
}
public function getVideoFile()
{
return $this->videoFile;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getDescriptionCourte(): ?string
{
return $this->descriptionCourte;
}
public function setDescriptionCourte(?string $descriptionCourte): static
{
$this->descriptionCourte = $descriptionCourte;
return $this;
}
}