src/Entity/Blog/Post.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Blog;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\UploadedFile;
  5. /**
  6.  * @ORM\Entity
  7.  * @ORM\Table(name="blog_post")
  8.  * @ORM\Entity(repositoryClass="App\Repository\PostRepository")
  9.  */
  10. class Post
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue(strategy="AUTO")
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string")
  20.      */
  21.     private $title;
  22.     /**
  23.      * @ORM\Column(type="text")
  24.      */
  25.     private $description;
  26.     /**
  27.      * @ORM\Column(type="text", nullable=true)
  28.      */
  29.     private $metaTitle;
  30.     /**
  31.      * @ORM\Column(type="text", nullable=true)
  32.      */
  33.     private $metaDescription;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     private $publishedAt;
  38.     private $uploadedFile;
  39.     /**
  40.      * @ORM\Column(type="string")
  41.      */
  42.     private $image;
  43.     /**
  44.      * @ORM\ManyToOne(targetEntity="App\Entity\Blog\Category", inversedBy="posts")
  45.      */
  46.     private $category;
  47.     public function getSlug() {
  48.         return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/''-'$this->title), '-'));
  49.     }
  50.     /**
  51.      * Get id
  52.      *
  53.      * @return integer
  54.      */
  55.     public function getId()
  56.     {
  57.         return $this->id;
  58.     }
  59.     /**
  60.      * Set title
  61.      *
  62.      * @param string $title
  63.      *
  64.      * @return Post
  65.      */
  66.     public function setTitle($title)
  67.     {
  68.         $this->title $title;
  69.         return $this;
  70.     }
  71.     /**
  72.      * Get title
  73.      *
  74.      * @return string
  75.      */
  76.     public function getTitle()
  77.     {
  78.         return $this->title;
  79.     }
  80.     /**
  81.      * Set description
  82.      *
  83.      * @param string $description
  84.      *
  85.      * @return Post
  86.      */
  87.     public function setDescription($description)
  88.     {
  89.         $this->description $description;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Get description
  94.      *
  95.      * @return string
  96.      */
  97.     public function getDescription()
  98.     {
  99.         return $this->description==null '' $this->description;
  100.     }
  101.     /**
  102.      * Set metaTitle
  103.      *
  104.      * @param string $metaTitle
  105.      *
  106.      * @return Post
  107.      */
  108.     public function setMetaTitle($metaTitle)
  109.     {
  110.         $this->metaTitle $metaTitle;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get metaTitle
  115.      *
  116.      * @return string
  117.      */
  118.     public function getMetaTitle()
  119.     {
  120.         return $this->metaTitle;
  121.     }
  122.     /**
  123.      * Set metaDescription
  124.      *
  125.      * @param string $metaDescription
  126.      *
  127.      * @return Post
  128.      */
  129.     public function setMetaDescription($metaDescription)
  130.     {
  131.         $this->metaDescription $metaDescription;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get metaDescription
  136.      *
  137.      * @return string
  138.      */
  139.     public function getMetaDescription()
  140.     {
  141.         return $this->metaDescription;
  142.     }
  143.     /**
  144.      * Set publishedAt
  145.      *
  146.      * @param \DateTime $publishedAt
  147.      *
  148.      * @return Post
  149.      */
  150.     public function setPublishedAt($publishedAt)
  151.     {
  152.         $this->publishedAt $publishedAt;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get publishedAt
  157.      *
  158.      * @return \DateTime
  159.      */
  160.     public function getPublishedAt()
  161.     {
  162.         return $this->publishedAt;
  163.     }
  164.     /**
  165.      * Set category
  166.      *
  167.      * @param \App\Entity\Blog\Category $category
  168.      *
  169.      * @return Post
  170.      */
  171.     public function setCategory(\App\Entity\Blog\Category $category null)
  172.     {
  173.         $this->category $category;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get category
  178.      *
  179.      * @return \App\Entity\Blog\Category
  180.      */
  181.     public function getCategory()
  182.     {
  183.         return $this->category;
  184.     }
  185.     /**
  186.      * Set image
  187.      *
  188.      * @param string $image
  189.      *
  190.      * @return Post
  191.      */
  192.     public function setImage($image)
  193.     {
  194.         $this->image $image;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get image
  199.      *
  200.      * @return string
  201.      */
  202.     public function getImage()
  203.     {
  204.         return $this->image;
  205.     }
  206.     /**
  207.     * Set uploadedFile
  208.     *
  209.     * @param string $uploadedFile
  210.     *
  211.     * @return Medium
  212.     */
  213.     public function setUploadedFile($uploadedFile)
  214.     {
  215.         $this->uploadedFile $uploadedFile;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get uploadedFile
  220.      *
  221.      * @return UploadedFile
  222.      */
  223.     public function getUploadedFile()
  224.     {
  225.         return $this->uploadedFile;
  226.     }
  227. public function __construct()
  228.     {
  229.         $this->description "";
  230.     }
  231. }