<?php
namespace App\Entity;
use App\Repository\EventRepository;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
#[ORM\Entity(repositoryClass: EventRepository::class)]
#[Vich\Uploadable]
class Event
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'datetime')]
private $created_at;
#[ORM\Column(type: 'datetime')]
private $updated_at;
#[ORM\Column(type: 'datetime')]
private $date;
#[ORM\Column(type: 'text')]
private $description;
#[ORM\Column(type: 'string', length: 255)]
private $telephone;
#[ORM\Column(type: 'string', length: 255)]
private $ville;
#[ORM\Column(type: 'string', length: 255)]
private $link;
#[ORM\Column(type: 'string', length: 255)]
private $filename;
#[Vich\UploadableField(mapping: "event", fileNameProperty: "filename")]
#[Assert\Image(
mimeTypes: ['image/jpeg', 'image/png', 'image/jpg', 'image/gif'],
mimeTypesMessage: "Les formats d'images acceptés sont : .jpeg .png .jpg and .gif"
)]
private ?File $imageFile = null;
#[ORM\Column(type: 'integer', nullable: true)]
private $position;
public function __construct()
{
$this->created_at = new DateTime('now');
$this->updated_at = new DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
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 getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(string $link): self
{
$this->link = $link;
return $this;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(string $filename): self
{
$this->filename = $filename;
return $this;
}
/**
* @return null|File
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param null|File $imageFile
*/
public function setImageFile(?File $imageFile): self
{
$this->imageFile = $imageFile;
if ($this->imageFile instanceof UploadedFile) {
$this->updated_at = new \DateTime('now');
}
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
}