<?php
namespace App\Entity\Posts;
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\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
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 Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\Posts\PostsRepository")
* @UniqueEntity("name")
* @Vich\Uploadable
*/
class Posts
{
use IdTrait;
use OrdreTrait;
use DatesTrait;
use SlugTrait;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Veuillez saisir le nom du post")
*/
private $name;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $extrait;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="boolean")
*/
private $online;
/**
* @ORM\Column(type="integer", nullable=true, options={"default": 0})
*/
private $views;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="posts_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\ManyToOne(targetEntity="App\Entity\User", inversedBy="posts")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $updatedBy;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Posts\Categorieposts", inversedBy="posts")
*/
private $categories;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Posts\Mediaposts", mappedBy="posts")
*/
private $mediaposts;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="bandeau_posts", 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="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telephone;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $lieu;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $heuredetravail;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $siteweb;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebook;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $twitter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $instagram;
/**
* @ORM\Column(type="boolean")
*/
private $reserved;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $longitude;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $latitude;
/**
* @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;
}
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;
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
* @return Posts
* @throws Exception
*/
public function setImageFile(?File $imageFile): Posts
{
$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 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(): ?Categorieposts
{
return $this->categories;
}
public function setCategories(?Categorieposts $categories): self
{
$this->categories = $categories;
return $this;
}
/**
* @return Collection|Mediaposts[]
*/
public function getMediaposts(): Collection
{
return $this->mediaposts;
}
public function addMediapost(Mediaposts $mediaposts): self
{
if (!$this->mediaposts->contains($mediaposts)) {
$this->mediaposts[] = $mediaposts;
$mediaposts->setPosts($this);
}
return $this;
}
public function removeMediapost(Mediaposts $mediaposts): self
{
if ($this->mediaposts->contains($mediaposts)) {
$this->mediaposts->removeElement($mediaposts);
// set the owning side to null (unless already changed)
if ($mediaposts->getPosts() === $this) {
$mediaposts->setPosts(null);
}
}
return $this;
}
/**
* @return File|null
*/
public function getImageBandeauFile(): ?File
{
return $this->imageBandeauFile;
}
/**
* @param File|null $imageBandeauFile
* @return Posts
*/
public function setImageBandeauFile(?File $imageBandeauFile): Posts
{
$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 getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(?string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getLieu(): ?string
{
return $this->lieu;
}
public function setLieu(?string $lieu): self
{
$this->lieu = $lieu;
return $this;
}
public function getHeuredetravail(): ?string
{
return $this->heuredetravail;
}
public function setHeuredetravail(?string $heuredetravail): self
{
$this->heuredetravail = $heuredetravail;
return $this;
}
public function getSiteweb(): ?string
{
return $this->siteweb;
}
public function setSiteweb(?string $siteweb): self
{
$this->siteweb = $siteweb;
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getTwitter(): ?string
{
return $this->twitter;
}
public function setTwitter(?string $twitter): self
{
$this->twitter = $twitter;
return $this;
}
public function getInstagram(): ?string
{
return $this->instagram;
}
public function setInstagram(?string $instagram): self
{
$this->instagram = $instagram;
return $this;
}
public function getReserved(): ?bool
{
return $this->reserved;
}
public function setReserved(bool $reserved): self
{
$this->reserved = $reserved;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(?string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(?string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function __toString()
{
return $this->name;
}
public function getFeatured(): ?bool
{
return $this->featured;
}
public function setFeatured(bool $featured): self
{
$this->featured = $featured;
return $this;
}
}