<?php
namespace App\Entity\Salons;
use App\Entity\Common\DatesTrait;
use App\Entity\Common\IdTrait;
use App\Entity\Common\OrdreTrait;
use App\Entity\Common\SlugTrait;
use App\Entity\User;
use DateTimeImmutable;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
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="App\Repository\Salons\SalonsRepository")
* @UniqueEntity("name")
* @Vich\Uploadable
*/
class Salons
{
use IdTrait;
use OrdreTrait;
use DatesTrait;
use SlugTrait;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Veuillez saisir un nom")
*/
private $name;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $extrait;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="salons_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="boolean")
*/
private $online;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": 0})
*/
private $views;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="salons")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $updatedBy;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Salons\Categoriesalons", inversedBy="salons")
*/
private $categories;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Salons\Mediasalons", mappedBy="salons")
*/
private $mediasalons;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $shortTitle;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $videoLink;
/**
* @ORM\Column(type="boolean")
*/
private $nouveau;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="bandeau_cover", fileNameProperty="bandeaufile")
* @var File|null
* @Assert\Image(
* mimeTypes={"image/jpeg", "image/png"},
*
* maxHeight=230,
* maxWidth=1920,
* maxHeightMessage="Votre image doit faire 230 d'hauteur",
* maxWidthMessage="Votre image doit faire 1920 de largeur"
* )
*/
private $imageBandeauFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bandeaufile;
/**
* @ORM\Column(type="boolean")
*/
private $featured;
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getExtrait(): ?string
{
return $this->extrait;
}
public function setExtrait(?string $extrait): self
{
$this->extrait = $extrait;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
* @return Salons
* @throws Exception
*/
public function setImageFile(?File $imageFile): Salons
{
$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 getViews(): ?int
{
return $this->views;
}
public function setViews(int $views): self
{
$this->views = $views;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getCategories(): ?Categoriesalons
{
return $this->categories;
}
public function setCategories(?Categoriesalons $categories): self
{
$this->categories = $categories;
return $this;
}
/**
* @return Collection|Mediasalons[]
*/
public function getMediasalons(): Collection
{
return $this->mediasalons;
}
public function addMediasalon(Mediasalons $mediasalons): self
{
if (!$this->mediasalons->contains($mediasalons)) {
$this->mediasalons[] = $mediasalons;
$mediasalons->setSalons($this);
}
return $this;
}
public function removeMediasalon(Mediasalons $mediasalons): self
{
if ($this->mediasalons->contains($mediasalons)) {
$this->mediasalons->removeElement($mediasalons);
// set the owning side to null (unless already changed)
if ($mediasalons->getSalons() === $this) {
$mediasalons->setSalons(null);
}
}
return $this;
}
public function getShortTitle(): ?string
{
return $this->shortTitle;
}
public function setShortTitle(?string $shortTitle): self
{
$this->shortTitle = $shortTitle;
return $this;
}
public function getVideoLink(): ?string
{
return $this->videoLink;
}
public function setVideoLink(?string $videoLink): self
{
$this->videoLink = $videoLink;
return $this;
}
public function getNouveau(): ?bool
{
return $this->nouveau;
}
public function setNouveau(bool $nouveau): self
{
$this->nouveau = $nouveau;
return $this;
}
/**
* @return File|null
*/
public function getImageBandeauFile(): ?File
{
return $this->imageBandeauFile;
}
/**
* @param File|null $imageBandeauFile
* @return Salons
*/
public function setImageBandeauFile(?File $imageBandeauFile): Salons
{
$this->imageBandeauFile = $imageBandeauFile;
if ($this->imageBandeauFile 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 getBandeaufile(): ?string
{
return $this->bandeaufile;
}
public function setBandeaufile(?string $bandeaufile): self
{
$this->bandeaufile = $bandeaufile;
return $this;
}
public function getFeatured(): ?bool
{
return $this->featured;
}
public function setFeatured(bool $featured): self
{
$this->featured = $featured;
return $this;
}
}