src/Entity/CityPost.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\CityPostRepository")
  11.  * @Vich\Uploadable
  12.  */
  13. class CityPost
  14. {
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $slug;
  29.     /**
  30.      * @ORM\Column(type="string", length=255, nullable=true)
  31.      */
  32.     private $zipcode;
  33.     /**
  34.      * @ORM\Column(type="text", nullable=true)
  35.      */
  36.     private $wording;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $bannerPath;
  41.     /**
  42.      * @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg"})
  43.      * @Vich\UploadableField(mapping="city_banner", fileNameProperty="bannerPath")
  44.      * @var File
  45.      */
  46.     private $bannerFile;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      * @Gedmo\Timestampable(on="update")
  50.      */
  51.     private $updatedAt;
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getName(): ?string
  57.     {
  58.         return $this->name;
  59.     }
  60.     public function setName(string $name): self
  61.     {
  62.         $this->name $name;
  63.         return $this;
  64.     }
  65.     public function getZipcode(): ?string
  66.     {
  67.         return $this->zipcode;
  68.     }
  69.     public function setZipcode(?string $zipcode): self
  70.     {
  71.         $this->zipcode $zipcode;
  72.         return $this;
  73.     }
  74.     public function getWording(): ?string
  75.     {
  76.         return $this->wording;
  77.     }
  78.     public function setWording(?string $wording): self
  79.     {
  80.         $this->wording $wording;
  81.         return $this;
  82.     }
  83.     public function getBannerPath(): ?string
  84.     {
  85.         return $this->bannerPath;
  86.     }
  87.     public function setBannerPath(?string $bannerPath): self
  88.     {
  89.         $this->bannerPath $bannerPath;
  90.         return $this;
  91.     }
  92.     public function getSlug(): ?string
  93.     {
  94.         return $this->slug;
  95.     }
  96.     public function setSlug(string $slug): self
  97.     {
  98.         $this->slug $slug;
  99.         return $this;
  100.     }
  101.     public function getUpdatedAt(): ?\DateTimeInterface
  102.     {
  103.         return $this->updatedAt;
  104.     }
  105.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  106.     {
  107.         $this->updatedAt $updatedAt;
  108.         return $this;
  109.     }
  110.     public function isUpdated():bool
  111.     {
  112.         if($this->updatedAt !== NULL) {
  113.             if(date_diff($this->updatedAt, new DateTime('now'))->days 31 ) {
  114.                 return true;
  115.             }
  116.         }
  117.         return false;
  118.     }
  119.     public function hasBanner(){
  120.         return !is_null($this->bannerPath);
  121.     }
  122.     public function setBannerFile(File $image null)
  123.     {
  124.         $this->bannerFile $image;
  125.     }
  126.     public function getBannerFile()
  127.     {
  128.         return $this->bannerFile;
  129.     }
  130. }