<?php
namespace App\Entity;
use App\Entity\Common\DatesTrait;
use App\Entity\Common\IdTrait;
use App\Entity\Common\OrdreTrait;
use App\Entity\Common\SlugTrait;
use App\Repository\EventsRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=EventsRepository::class)
* @Vich\Uploadable
*/
class Events
{
use IdTrait;
use OrdreTrait;
use DatesTrait;
use SlugTrait;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Veuillez saisir le nom de l'event")
*/
private $name;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="events_image", fileNameProperty="filename")
* @var File|null
* @Assert\Image(
* mimeTypes={"image/jpeg", "image/png"},
*
* maxHeight=1280,
* maxWidth=1920,
* maxHeightMessage="Votre image doit faire 1280 d'hauteur",
* maxWidthMessage="Votre image doit faire 1920 de largeur"
* )
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $localisation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $date;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=Periodes::class, inversedBy="events")
*/
private $periodes;
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
* @return Events
* @throws Exception
*/
public function setImageFile(?File $imageFile): Events
{
$this->imageFile = $imageFile;
if ($this->imageFile instanceof UploadedFile) {
// 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
$this->updatedAt = new DateTimeImmutable('now');
}
return $this;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(?string $filename): self
{
$this->filename = $filename;
return $this;
}
/**
* @return mixed
*/
public function getLocalisation()
{
return $this->localisation;
}
/**
* @param mixed localisation
* @return Events
*/
public function setLocalisation($localisation): Events
{
$this->localisation = $localisation;
return $this;
}
/**
* @return mixed
*/
public function getDate()
{
return $this->date;
}
/**
* @param mixed $date
* @return Events
*/
public function setDate($date): Events
{
$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 getPeriodes(): ?Periodes
{
return $this->periodes;
}
public function setPeriodes(?Periodes $periodes): self
{
$this->periodes = $periodes;
return $this;
}
}