<?php
namespace App\Entity;
use App\Entity\TimestampableTrait;
use App\Repository\ArticleRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ArticleRepository::class)
* @UniqueEntity(fields={"title"}, message="Ce titre est déjà utilisé.")
*/
class Article
{
use TimestampableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $title;
/**
* @Gedmo\Slug(fields={"title"}, unique=true)
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="boolean")
*/
private $status = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Assert\Image(maxSize="2M")
*/
private $file;
/**
* @ORM\ManyToOne(targetEntity=ArticleCategory::class, inversedBy="articles")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $keywords;
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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function isStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function setFile($file)
{
$this->file = $file;
return $this;
}
public function getFile()
{
return $this->file;
}
public function getCategory(): ?ArticleCategory
{
return $this->category;
}
public function setCategory(?ArticleCategory $category): self
{
$this->category = $category;
return $this;
}
public function getKeywords(): ?string
{
return $this->keywords;
}
public function setKeywords(?string $keywords): self
{
$this->keywords = $keywords;
return $this;
}
}