src/Entity/Publication.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PublicationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @ORM\Entity(repositoryClass=PublicationRepository::class)
  10.  * @Vich\Uploadable
  11.  */
  12. class Publication
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=190)
  22.      */
  23.     private $title;
  24.     /**
  25.      * @var string|null
  26.      *
  27.      * @Gedmo\Slug(fields={"title"})
  28.      * @ORM\Column(length=190, unique=true)
  29.      */
  30.     private $slug;
  31.     /**
  32.      * @Gedmo\Timestampable(on="create")
  33.      * @ORM\Column(name="created", type="datetime")
  34.      */
  35.     private $created;
  36.     /**
  37.      * @Gedmo\Timestampable(on="change", field={"title", "content","image"})
  38.      * @ORM\Column(name="updated", type="datetime", nullable=true)
  39.      */
  40.     private $updated;
  41.     /**
  42.      * @ORM\Column(type="text")
  43.      */
  44.     private $content;
  45.     /**
  46.      * @ORM\Column(type="string", length=190, nullable=true)
  47.      */
  48.     private $image;
  49.     /**
  50.      * @Vich\UploadableField(mapping="images_publication", fileNameProperty="image")
  51.      * @var File | null
  52.      */
  53.     private $imageFile;
  54.     /**
  55.      * @ORM\Column(type="string", length=190)
  56.      */
  57.     private $category;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="publications")
  60.      */
  61.     private $author;
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getTitle(): ?string
  67.     {
  68.         return $this->title;
  69.     }
  70.     public function setTitle(string $title): self
  71.     {
  72.         $this->title = $title;
  73.         return $this;
  74.     }
  75.     public function getContent(): ?string
  76.     {
  77.         return $this->content;
  78.     }
  79.     public function setContent(string $content): self
  80.     {
  81.         $this->content = $content;
  82.         return $this;
  83.     }
  84.     public function getImage(): ?string
  85.     {
  86.         return $this->image;
  87.     }
  88.     public function setImage(?string $image): self
  89.     {
  90.         $this->image = $image;
  91.         return $this;
  92.     }
  93.     public function setImageFile(File $image = null)
  94.     {
  95.         $this->imageFile = $image;
  96.         if ($image) {
  97.             $this->updatedAt = new \DateTime('now');
  98.         }
  99.     }
  100.     public function getImageFile()
  101.     {
  102.         return $this->imageFile;
  103.     }
  104.     public function getCategory(): ?string
  105.     {
  106.         return $this->category;
  107.     }
  108.     public function setCategory(string $category): self
  109.     {
  110.         $this->category = $category;
  111.         return $this;
  112.     }
  113.     public function getAuthor(): ?User
  114.     {
  115.         return $this->author;
  116.     }
  117.     public function setAuthor(?User $author): self
  118.     {
  119.         $this->author = $author;
  120.         return $this;
  121.     }
  122.     public function getCreated()
  123.     {
  124.         return $this->created;
  125.     }
  126.     public function getUpdated()
  127.     {
  128.         return $this->updated;
  129.     }
  130.     public function getSlug()
  131.     {
  132.         return $this->slug;
  133.     }
  134. }