<?php
namespace App\Entity;
use App\Repository\PublicationRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=PublicationRepository::class)
* @Vich\Uploadable
*/
class Publication
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=190)
*/
private $title;
/**
* @var string|null
*
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(length=190, unique=true)
*/
private $slug;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* @Gedmo\Timestampable(on="change", field={"title", "content","image"})
* @ORM\Column(name="updated", type="datetime", nullable=true)
*/
private $updated;
/**
* @ORM\Column(type="text")
*/
private $content;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="images_publication", fileNameProperty="image")
* @var File | null
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=190)
*/
private $category;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="publications")
*/
private $author;
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 getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$this->updatedAt = new \DateTime('now');
}
}
public function getImageFile()
{
return $this->imageFile;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getCreated()
{
return $this->created;
}
public function getUpdated()
{
return $this->updated;
}
public function getSlug()
{
return $this->slug;
}
}