src/Entity/Blog.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\BlogRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassBlogRepository::class)]
  10. #[ORM\Table(name"blogs")]
  11. #[ORM\HasLifecycleCallbacks]
  12. /**
  13.  * @Vich\Uploadable
  14.  */
  15. class Blog
  16. {
  17.     use Timestampable;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private $id;
  22.     #[ORM\Column(type'string'length255)]
  23.     #[Assert\NotBlank(message'Veuillez entrer un titre.')]
  24.     #[Assert\Length(min3minMessage'3 caractéres au minimum')]
  25.     private $title;
  26.     #[ORM\Column(type'text')]
  27.     #[Assert\NotBlank(message'Veuillez entrer une description.')]
  28.     #[Assert\Length(min10minMessage'10 caractéres au minimum')]
  29.     private $description;
  30.     /**
  31.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  32.      *
  33.      * @Vich\UploadableField(mapping="blog_image", fileNameProperty="imageName")
  34.      *
  35.      * @var File|null
  36.      */
  37.     private $imageFile;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private $imageName;
  40.     #[ORM\Column(type'boolean'nullabletrue)]
  41.     private $online;
  42.     #[ORM\Column(type'string'length255nullabletrue)]
  43.     private $fileName;
  44.     /**
  45.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  46.      *
  47.      * @Vich\UploadableField(mapping="blog_file", fileNameProperty="fileName")
  48.      *
  49.      * @var File|null
  50.      */
  51.     private $fileFile;
  52.     #[ORM\Column(type'string'length255nullabletrue)]
  53.     private $metaTitle;
  54.     #[ORM\Column(type'string'length255nullabletrue)]
  55.     private $metaDescription;
  56.     #[ORM\Column(type'string'length255nullabletrue)]
  57.     private $Slug;
  58.     #[ORM\Column(type'boolean')]
  59.     private $noIndex;
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getTitle(): ?string
  65.     {
  66.         return $this->title;
  67.     }
  68.     public function setTitle(string $title): self
  69.     {
  70.         $this->title $title;
  71.         return $this;
  72.     }
  73.     public function getDescription(): ?string
  74.     {
  75.         return $this->description;
  76.     }
  77.     public function setDescription(string $description): self
  78.     {
  79.         $this->description $description;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  84.      */
  85.     public function setImageFile(?File $imageFile null): void
  86.     {
  87.         $this->imageFile $imageFile;
  88.         if (null !== $imageFile) {
  89.             // It is required that at least one field changes if you are using doctrine
  90.             // otherwise the event listeners won't be called and the file is lost
  91.             $this->setUpdatedAt(new \DateTimeImmutable);
  92.         }
  93.     }
  94.     public function getImageFile(): ?File
  95.     {
  96.         return $this->imageFile;
  97.     }
  98.     public function getImageName(): ?string
  99.     {
  100.         return $this->imageName;
  101.     }
  102.     public function setImageName(?string $imageName): self
  103.     {
  104.         $this->imageName $imageName;
  105.         return $this;
  106.     }
  107.     public function isOnline(): ?bool
  108.     {
  109.         return $this->online;
  110.     }
  111.     public function setOnline(?bool $online): self
  112.     {
  113.         $this->online $online;
  114.         return $this;
  115.     }
  116.     public function getFileName(): ?string
  117.     {
  118.         return $this->fileName;
  119.     }
  120.     public function setFileName(?string $fileName): self
  121.     {
  122.         $this->fileName $fileName;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $fileFile
  127.      */
  128.     public function setFileFile(?File $fileFile null): void
  129.     {
  130.         $this->fileFile $fileFile;
  131.         if (null !== $fileFile) {
  132.             // It is required that at least one field changes if you are using doctrine
  133.             // otherwise the event listeners won't be called and the file is lost
  134.             $this->setUpdatedAt(new \DateTimeImmutable);
  135.         }
  136.     }
  137.     public function getFileFile(): ?File
  138.     {
  139.         return $this->fileFile;
  140.     }
  141.     public function getMetaTitle(): ?string
  142.     {
  143.         return $this->metaTitle;
  144.     }
  145.     public function setMetaTitle(?string $metaTitle): self
  146.     {
  147.         $this->metaTitle $metaTitle;
  148.         return $this;
  149.     }
  150.     public function getMetaDescription(): ?string
  151.     {
  152.         return $this->metaDescription;
  153.     }
  154.     public function setMetaDescription(?string $metaDescription): self
  155.     {
  156.         $this->metaDescription $metaDescription;
  157.         return $this;
  158.     }
  159.     public function getSlug(): ?string
  160.     {
  161.         return $this->Slug;
  162.     }
  163.     public function setSlug(?string $Slug): self
  164.     {
  165.         $this->Slug $Slug;
  166.         return $this;
  167.     }
  168.     public function isNoIndex(): ?bool
  169.     {
  170.         return $this->noIndex;
  171.     }
  172.     public function setNoIndex(bool $noIndex): self
  173.     {
  174.         $this->noIndex $noIndex;
  175.         return $this;
  176.     }
  177. }