<?php
namespace App\Entity;
use App\Repository\ArticleRepository;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ArticleRepository::class)]
class Article
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $title;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\ManyToOne(targetEntity: Admin::class, inversedBy: 'articles')]
#[ORM\JoinColumn(nullable: true)]
private $author;
#[ORM\Column(type: 'datetime')]
private $createdDate;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $slug;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cover;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $views;
#[ORM\ManyToMany(targetEntity: Category::class, mappedBy: 'articles')]
private $categories;
#[ORM\Column(type: 'boolean')]
private $published;
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'article', cascade: ['persist', 'remove'])]
private $comments;
#[ORM\Column(type: 'string', length: 255)]
private $status;
#[ORM\ManyToOne(targetEntity: Admin::class, inversedBy: 'reviewedArticles')]
private $reviewer;
#[ORM\Column(type: 'boolean', nullable: true)]
private $featured;
#[ORM\Column(type: 'datetime', nullable: true)]
private $featuredAt;
#[ORM\ManyToOne(targetEntity: WebsiteLanguage::class, inversedBy: 'articles')]
private $websiteLanguage;
#[ORM\Column(type: 'boolean')]
private $original;
#[ORM\Column(type: 'integer', nullable: true)]
private $unit;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $altCover;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $titleSeo;
#[ORM\Column(type: 'text', nullable: true)]
private $descriptionSeo;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $publishedAt = null;
public function __construct()
{
$this->createdDate = new DateTime();
$this->categories = new ArrayCollection();
$this->comments = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getAuthor(): ?Admin
{
return $this->author;
}
public function setAuthor(?Admin $author): self
{
$this->author = $author;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeInterface $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCover()
{
return $this->cover;
}
public function setCover($cover): self
{
$this->cover = $cover;
return $this;
}
public function getViews(): ?string
{
return $this->views;
}
public function setViews(?string $views): self
{
$this->views = $views;
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
$category->addArticle($this);
}
return $this;
}
public function removeCategory(Category $category): self
{
if ($this->categories->removeElement($category)) {
$category->removeArticle($this);
}
return $this;
}
public function getPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): self
{
$this->published = $published;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setArticle($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getArticle() === $this) {
$comment->setArticle(null);
}
}
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getReviewer(): ?Admin
{
return $this->reviewer;
}
public function setReviewer(?Admin $reviewer): self
{
$this->reviewer = $reviewer;
return $this;
}
public function getFeatured(): ?bool
{
return $this->featured;
}
public function setFeatured(?bool $featured): self
{
$this->featured = $featured;
return $this;
}
public function getFeaturedAt(): ?\DateTimeInterface
{
return $this->featuredAt;
}
public function setFeaturedAt(?\DateTimeInterface $featuredAt): self
{
$this->featuredAt = $featuredAt;
return $this;
}
public function getWebsiteLanguage(): ?WebsiteLanguage
{
return $this->websiteLanguage;
}
public function setWebsiteLanguage(?WebsiteLanguage $websiteLanguage): self
{
$this->websiteLanguage = $websiteLanguage;
return $this;
}
public function getOriginal(): ?bool
{
return $this->original;
}
public function setOriginal(bool $original): self
{
$this->original = $original;
return $this;
}
public function getUnit(): ?int
{
return $this->unit;
}
public function setUnit(int $unit): self
{
$this->unit = $unit;
return $this;
}
public function getAltCover(): ?string
{
return $this->altCover;
}
public function setAltCover(?string $altCover): self
{
$this->altCover = $altCover;
return $this;
}
public function getTitleSeo(): ?string
{
return $this->titleSeo;
}
public function setTitleSeo(?string $titleSeo): self
{
$this->titleSeo = $titleSeo;
return $this;
}
public function getDescriptionSeo(): ?string
{
return $this->descriptionSeo;
}
public function setDescriptionSeo(?string $descriptionSeo): self
{
$this->descriptionSeo = $descriptionSeo;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->publishedAt;
}
public function setPublishedAt(?\DateTimeInterface $publishedAt): static
{
$this->publishedAt = $publishedAt;
return $this;
}
}