<?php
namespace App\Entity;
use App\Repository\EasterEggRepository;
use App\Traits\DateTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use JMS\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=EasterEggRepository::class)
* @ORM\HasLifecycleCallbacks
* @Vich\Uploadable
*
* @UniqueEntity(
* fields={"slug"},
* message="Ce slug existe déjà."
* )
*/
class EasterEgg
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "easter_egg",
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "easter_egg",
* })
*/
private $label;
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Le slug ne peut pas être vide.")
*
* @Assert\Regex(
* pattern="/^[a-z0-9]+(?:-[a-z0-9]+)*$/",
* message="Le slug doit contenir uniquement des lettres minuscules, chiffres et tirets."
* )
*
* @Groups({
* "easter_egg",
* })
*/
private $slug;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Groups({
* "easter_egg",
* })
*/
private $image;
// Vich Uploader
/**
* @Vich\UploadableField(mapping="easter_egg_images", fileNameProperty="image")
* @var File|null
* @Assert\File(
* mimeTypes={"image/jpeg", "image/png", "image/gif"},
* mimeTypesMessage="Veuillez uploader une image JPEG, PNG ou GIF."
* )
*/
private ?File $imageFile = null;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @Groups({
* "easter_egg",
* })
*/
private ?int $value = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Groups({
* "easter_egg",
* })
*/
private ?\DateTime $dateStart;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Groups({
* "easter_egg",
* })
*/
private ?\DateTime $dateEnd;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "easter_egg",
* })
*/
private $location;
use DateTrait;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage( ?string $image ): self
{
$this->image = $image;
return $this;
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File $imageFile
*
* @return void
*/
public function setImageFile( File $imageFile ): void
{
$this->imageFile = $imageFile;
if ( NULL !== $imageFile ) {
// 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 \DateTime();
}
}
public function getValue(): ?int
{
return $this->value;
}
public function setValue(?int $value): self
{
$this->value = $value;
return $this;
}
public function getDateStart(): ?\DateTime
{
return $this->dateStart;
}
public function setDateStart(?\DateTime $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getDateEnd(): ?\DateTime
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTime $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(string $location): self
{
$this->location = $location;
return $this;
}
}