<?php
namespace App\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\CityPostRepository")
* @Vich\Uploadable
*/
class CityPost
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zipcode;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $wording;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bannerPath;
/**
* @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg"})
* @Vich\UploadableField(mapping="city_banner", fileNameProperty="bannerPath")
* @var File
*/
private $bannerFile;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
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 getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
public function getWording(): ?string
{
return $this->wording;
}
public function setWording(?string $wording): self
{
$this->wording = $wording;
return $this;
}
public function getBannerPath(): ?string
{
return $this->bannerPath;
}
public function setBannerPath(?string $bannerPath): self
{
$this->bannerPath = $bannerPath;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function isUpdated():bool
{
if($this->updatedAt !== NULL) {
if(date_diff($this->updatedAt, new DateTime('now'))->days < 31 ) {
return true;
}
}
return false;
}
public function hasBanner(){
return !is_null($this->bannerPath);
}
public function setBannerFile(File $image = null)
{
$this->bannerFile = $image;
}
public function getBannerFile()
{
return $this->bannerFile;
}
}