src/Entity/Post.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\PostRepository")
  9.  */
  10. class Post
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $title;
  22.     /**
  23.      * @ORM\Column(type="text")
  24.      */
  25.     private $content;
  26.     /**
  27.      * @ORM\Column(type="datetime")
  28.      */
  29.     private $createdAt;
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $publishedAt;
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity=Category::class, inversedBy="posts")
  36.      */
  37.     private $categories;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity=Tag::class, inversedBy="posts")
  40.      */
  41.     private $tags;
  42.     /**
  43.      * @ORM\OneToOne(targetEntity=Media::class, cascade={"persist", "remove"})
  44.      */
  45.     private $image;
  46.     /**
  47.      * @ORM\Column(type="datetime", nullable=true)
  48.      */
  49.     private $updated_at;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $slug;
  54.     public function __construct()
  55.     {
  56.         $this->categories = new ArrayCollection();
  57.         $this->tags = new ArrayCollection();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getTitle(): ?string
  64.     {
  65.         return $this->title;
  66.     }
  67.     public function setTitle(string $title): self
  68.     {
  69.         $this->title $title;
  70.         return $this;
  71.     }
  72.     public function getContent(): ?string
  73.     {
  74.         return $this->content;
  75.     }
  76.     public function setContent(string $content): self
  77.     {
  78.         $this->content $content;
  79.         return $this;
  80.     }
  81.     public function getCreatedAt(): ?\DateTimeInterface
  82.     {
  83.         return $this->createdAt;
  84.     }
  85.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  86.     {
  87.         $this->createdAt $createdAt;
  88.         return $this;
  89.     }
  90.     public function getPublishedAt(): ?\DateTimeInterface
  91.     {
  92.         return $this->publishedAt;
  93.     }
  94.     public function setPublishedAt(\DateTimeInterface $publishedAt): self
  95.     {
  96.         $this->publishedAt $publishedAt;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return Collection<int, Category>
  101.      */
  102.     public function getCategories(): Collection
  103.     {
  104.         return $this->categories;
  105.     }
  106.     public function addCategory(Category $category): self
  107.     {
  108.         if (!$this->categories->contains($category)) {
  109.             $this->categories[] = $category;
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeCategory(Category $category): self
  114.     {
  115.         $this->categories->removeElement($category);
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return Collection<int, Tag>
  120.      */
  121.     public function getTags(): Collection
  122.     {
  123.         return $this->tags;
  124.     }
  125.     public function addTag(Tag $tag): self
  126.     {
  127.         if (!$this->tags->contains($tag)) {
  128.             $this->tags[] = $tag;
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeTag(Tag $tag): self
  133.     {
  134.         $this->tags->removeElement($tag);
  135.         return $this;
  136.     }
  137.     public function getImage(): ?Media
  138.     {
  139.         return $this->image;
  140.     }
  141.     public function setImage(?Media $image): self
  142.     {
  143.         $this->image $image;
  144.         return $this;
  145.     }
  146.     public function getUpdatedAt(): ?\DateTimeInterface
  147.     {
  148.         return $this->updated_at;
  149.     }
  150.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  151.     {
  152.         $this->updated_at $updated_at;
  153.         return $this;
  154.     }
  155.     public function getSlug(): ?string
  156.     {
  157.         return $this->slug;
  158.     }
  159.     public function setSlug(?string $slug): self
  160.     {
  161.         $this->slug $slug;
  162.         return $this;
  163.     }
  164. }