<?php
namespace App\Entity;
use App\Repository\PostRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JetBrains\PhpStorm\Pure;
#[ORM\Entity(repositoryClass: PostRepository::class)]
class Post
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[ORM\Column(type: 'text', nullable: true)]
private $summary;
#[ORM\Column(type: 'text')]
private $description;
#[ORM\Column(type: 'string', length: 255)]
private $slug;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $image;
#[ORM\Column(type: 'datetime_immutable')]
private $createdAt;
#[ORM\Column(type: 'datetime_immutable')]
private $updatedAt;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'posts')]
private $user;
#[ORM\Column(type: 'datetime', nullable: true)]
private $publishedAt;
#[ORM\Column(type: 'boolean')]
private $status;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'posts')]
private $author;
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'posts')]
private $category;
#[ORM\Column(type: 'string', length: 50)]
private $type;
#[ORM\Column(type: 'integer', nullable: true)]
private $view;
#[ORM\OneToMany(mappedBy: 'post', targetEntity: Media::class)]
private $media;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'posts')]
private $parent;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private $posts;
#[ORM\Column(type: 'boolean')]
private $is_translated;
#[ORM\Column(type: 'string', length: 255)]
private $lang;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $icon;
public function __construct()
{
$this->category = new ArrayCollection();
$this->media = new ArrayCollection();
$this->createdAt = new \DatetimeImmutable();
$this->updatedAt = new \DatetimeImmutable();
$this->posts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getSummary(): ?string
{
return $this->summary;
}
public function setSummary(?string $summary): self
{
$this->summary = $summary;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->publishedAt;
}
public function setPublishedAt(?\DateTimeInterface $publishedAt): self
{
$this->publishedAt = $publishedAt;
return $this;
}
public function getStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
/**
* @return Collection<int, Category>
*/
public function getCategory(): Collection
{
return $this->category;
}
public function addCategory(Category $category): self
{
if (!$this->category->contains($category)) {
$this->category[] = $category;
}
return $this;
}
public function removeCategory(Category $category): self
{
$this->category->removeElement($category);
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getView(): ?int
{
return $this->view;
}
public function setView(?int $view): self
{
$this->view = $view;
return $this;
}
/**
* @return Collection<int, Media>
*/
public function getMedia(): Collection
{
return $this->media;
}
public function addMedium(Media $medium): self
{
if (!$this->media->contains($medium)) {
$this->media[] = $medium;
$medium->setPost($this);
}
return $this;
}
public function removeMedium(Media $medium): self
{
if ($this->media->removeElement($medium)) {
// set the owning side to null (unless already changed)
if ($medium->getPost() === $this) {
$medium->setPost(null);
}
}
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(self $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setParent($this);
}
return $this;
}
public function removePost(self $post): self
{
if ($this->posts->removeElement($post)) {
// set the owning side to null (unless already changed)
if ($post->getParent() === $this) {
$post->setParent(null);
}
}
return $this;
}
public function getIsTranslated(): ?bool
{
return $this->is_translated;
}
public function setIsTranslated(bool $is_translated): self
{
$this->is_translated = $is_translated;
return $this;
}
public function getLang(): ?string
{
return $this->lang;
}
public function setLang(string $lang): self
{
$this->lang = $lang;
return $this;
}
#[Pure] public function __toString(): string
{
return $this->getTitle();
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
}