<?php
namespace App\Entity\Salons;
use DateTime;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Table;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\Salons\CategoriesalonsRepository")
* @Table (name="categoriesalons")
* @UniqueEntity("name")
* @Vich\Uploadable
*/
class Categoriesalons
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Veuillez saisir le nom de la catégorie")
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"name"})
*/
private $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="categories_image", fileNameProperty="filename")
* @var File|null
* @Assert\Image(
* mimeTypes={"image/jpeg", "image/png"},
*
* maxHeight=250,
* maxWidth=1920,
* maxHeightMessage="Votre image doit faire 250 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="boolean")
*/
private $online;
/**
* @var DateTime $updatedAt
* @ORM\Column(type="datetime", nullable=true)
*
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="integer")
*/
private $ordre;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Salons\Salons", mappedBy="categories")
*/
private $salons;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="categories_image", fileNameProperty="coverfile")
* @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 $coverImageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $coverfile;
public function __construct()
{
$this->salons = new ArrayCollection();
}
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 getSlug(): ?string
{
return $this->slug;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
* @return Categoriesalons
* @throws \Exception
*/
public function setImageFile(?File $imageFile): Categoriesalons
{
$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;
}
public function getOnline(): ?bool
{
return $this->online;
}
public function setOnline(bool $online): self
{
$this->online = $online;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(int $ordre): self
{
$this->ordre = $ordre;
return $this;
}
/**
* @return Collection|Salons[]
*/
public function getSalons(): Collection
{
return $this->salons;
}
public function addSalon(Salons $salon): self
{
if (!$this->salons->contains($salon)) {
$this->salons[] = $salon;
$salon->setCategories($this);
}
return $this;
}
public function removeSalon(Salons $salon): self
{
if ($this->salons->contains($salon)) {
$this->salons->removeElement($salon);
// set the owning side to null (unless already changed)
if ($salon->getCategories() === $this) {
$salon->setCategories(null);
}
}
return $this;
}
public function __toString()
{
return $this->name;
}
/**
* @return File|null
*/
public function getCoverImageFile(): ?File
{
return $this->coverImageFile;
}
/**
* @param File|null $coverImageFile
* @return Categoriesalons
* @throws \Exception
*/
public function setCoverImageFile(?File $coverImageFile): Categoriesalons
{
$this->coverImageFile = $coverImageFile;
if ($this->coverImageFile 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 getCoverfile(): ?string
{
return $this->coverfile;
}
public function setCoverfile(?string $coverfile): self
{
$this->coverfile = $coverfile;
return $this;
}
}