src/Entity/Post.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PostRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JetBrains\PhpStorm\Pure;
  8. #[ORM\Entity(repositoryClassPostRepository::class)]
  9. class Post
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length255)]
  16.     private $title;
  17.     #[ORM\Column(type'text'nullabletrue)]
  18.     private $summary;
  19.     #[ORM\Column(type'text')]
  20.     private $description;
  21.     #[ORM\Column(type'string'length255)]
  22.     private $slug;
  23.     #[ORM\Column(type'string'length255nullabletrue)]
  24.     private $image;
  25.     #[ORM\Column(type'datetime_immutable')]
  26.     private $createdAt;
  27.     #[ORM\Column(type'datetime_immutable')]
  28.     private $updatedAt;
  29.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'posts')]
  30.     private $user;
  31.     #[ORM\Column(type'datetime'nullabletrue)]
  32.     private $publishedAt;
  33.     #[ORM\Column(type'boolean')]
  34.     private $status;
  35.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'posts')]
  36.     private $author;
  37.     #[ORM\ManyToMany(targetEntityCategory::class, inversedBy'posts')]
  38.     private $category;
  39.     #[ORM\Column(type'string'length50)]
  40.     private $type;
  41.     #[ORM\Column(type'integer'nullabletrue)]
  42.     private $view;
  43.     #[ORM\OneToMany(mappedBy'post'targetEntityMedia::class)]
  44.     private $media;
  45.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'posts')]
  46.     private $parent;
  47.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  48.     private $posts;
  49.     #[ORM\Column(type'boolean')]
  50.     private $is_translated;
  51.     #[ORM\Column(type'string'length255)]
  52.     private $lang;
  53.     #[ORM\Column(type'string'length255nullabletrue)]
  54.     private $icon;
  55.     public function __construct()
  56.     {
  57.         $this->category = new ArrayCollection();
  58.         $this->media = new ArrayCollection();
  59.         $this->createdAt = new \DatetimeImmutable();
  60.         $this->updatedAt = new \DatetimeImmutable();
  61.      $this->posts = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getTitle(): ?string
  68.     {
  69.         return $this->title;
  70.     }
  71.     public function setTitle(string $title): self
  72.     {
  73.         $this->title $title;
  74.         return $this;
  75.     }
  76.     public function getSummary(): ?string
  77.     {
  78.         return $this->summary;
  79.     }
  80.     public function setSummary(?string $summary): self
  81.     {
  82.         $this->summary $summary;
  83.         return $this;
  84.     }
  85.     public function getDescription(): ?string
  86.     {
  87.         return $this->description;
  88.     }
  89.     public function setDescription(string $description): self
  90.     {
  91.         $this->description $description;
  92.         return $this;
  93.     }
  94.     public function getSlug(): ?string
  95.     {
  96.         return $this->slug;
  97.     }
  98.     public function setSlug(string $slug): self
  99.     {
  100.         $this->slug $slug;
  101.         return $this;
  102.     }
  103.     public function getImage(): ?string
  104.     {
  105.         return $this->image;
  106.     }
  107.     public function setImage(?string $image): self
  108.     {
  109.         $this->image $image;
  110.         return $this;
  111.     }
  112.     public function getCreatedAt(): ?\DateTimeImmutable
  113.     {
  114.         return $this->createdAt;
  115.     }
  116.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  117.     {
  118.         $this->createdAt $createdAt;
  119.         return $this;
  120.     }
  121.     public function getUpdatedAt(): ?\DateTimeImmutable
  122.     {
  123.         return $this->updatedAt;
  124.     }
  125.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  126.     {
  127.         $this->updatedAt $updatedAt;
  128.         return $this;
  129.     }
  130.     public function getUser(): ?User
  131.     {
  132.         return $this->user;
  133.     }
  134.     public function setUser(?User $user): self
  135.     {
  136.         $this->user $user;
  137.         return $this;
  138.     }
  139.     public function getPublishedAt(): ?\DateTimeInterface
  140.     {
  141.         return $this->publishedAt;
  142.     }
  143.     public function setPublishedAt(?\DateTimeInterface $publishedAt): self
  144.     {
  145.         $this->publishedAt $publishedAt;
  146.         return $this;
  147.     }
  148.     public function getStatus(): ?bool
  149.     {
  150.         return $this->status;
  151.     }
  152.     public function setStatus(bool $status): self
  153.     {
  154.         $this->status $status;
  155.         return $this;
  156.     }
  157.     public function getAuthor(): ?User
  158.     {
  159.         return $this->author;
  160.     }
  161.     public function setAuthor(?User $author): self
  162.     {
  163.         $this->author $author;
  164.         return $this;
  165.     }
  166.     /**
  167.      * @return Collection<int, Category>
  168.      */
  169.     public function getCategory(): Collection
  170.     {
  171.         return $this->category;
  172.     }
  173.     public function addCategory(Category $category): self
  174.     {
  175.         if (!$this->category->contains($category)) {
  176.             $this->category[] = $category;
  177.         }
  178.         return $this;
  179.     }
  180.     public function removeCategory(Category $category): self
  181.     {
  182.         $this->category->removeElement($category);
  183.         return $this;
  184.     }
  185.     public function getType(): ?string
  186.     {
  187.         return $this->type;
  188.     }
  189.     public function setType(string $type): self
  190.     {
  191.         $this->type $type;
  192.         return $this;
  193.     }
  194.     public function getView(): ?int
  195.     {
  196.         return $this->view;
  197.     }
  198.     public function setView(?int $view): self
  199.     {
  200.         $this->view $view;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection<int, Media>
  205.      */
  206.     public function getMedia(): Collection
  207.     {
  208.         return $this->media;
  209.     }
  210.     public function addMedium(Media $medium): self
  211.     {
  212.         if (!$this->media->contains($medium)) {
  213.             $this->media[] = $medium;
  214.             $medium->setPost($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeMedium(Media $medium): self
  219.     {
  220.         if ($this->media->removeElement($medium)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($medium->getPost() === $this) {
  223.                 $medium->setPost(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function getParent(): ?self
  229.     {
  230.         return $this->parent;
  231.     }
  232.     public function setParent(?self $parent): self
  233.     {
  234.         $this->parent $parent;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, self>
  239.      */
  240.     public function getPosts(): Collection
  241.     {
  242.         return $this->posts;
  243.     }
  244.     public function addPost(self $post): self
  245.     {
  246.         if (!$this->posts->contains($post)) {
  247.             $this->posts[] = $post;
  248.             $post->setParent($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removePost(self $post): self
  253.     {
  254.         if ($this->posts->removeElement($post)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($post->getParent() === $this) {
  257.                 $post->setParent(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262.     public function getIsTranslated(): ?bool
  263.     {
  264.         return $this->is_translated;
  265.     }
  266.     public function setIsTranslated(bool $is_translated): self
  267.     {
  268.         $this->is_translated $is_translated;
  269.         return $this;
  270.     }
  271.     public function getLang(): ?string
  272.     {
  273.         return $this->lang;
  274.     }
  275.     public function setLang(string $lang): self
  276.     {
  277.         $this->lang $lang;
  278.         return $this;
  279.     }
  280.     #[Pure] public function __toString(): string
  281.     {
  282.         return $this->getTitle();
  283.     }
  284.     public function getIcon(): ?string
  285.     {
  286.         return $this->icon;
  287.     }
  288.     public function setIcon(?string $icon): self
  289.     {
  290.         $this->icon $icon;
  291.         return $this;
  292.     }
  293. }