src/Entity/Post.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PostRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClassPostRepository::class)]
  8. class Post
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  12.     #[ORM\Column(type"integer")]
  13.     private ?int $id null;
  14.     #[ORM\Column(type"datetime")]
  15.     private ?\DateTimeInterface $createdAt null;
  16.     #[ORM\Column(length100)]
  17.     private ?string $title null;
  18.     #[ORM\Column(type"text")]
  19.     private ?string $body null;
  20.     #[ORM\Column(length50)]
  21.     private ?string $genre null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $photo null;
  24.     #[Assert\Image(mimeTypes: ["image/jpeg""image/png"])]
  25.     private ?File $photoFile null;
  26.     #[ORM\Column(name"epigraph"nullabletrue)]
  27.     private ?string $epigraph null;
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getCreatedAt(): ?\DateTimeInterface
  33.     {
  34.         return $this->createdAt;
  35.     }
  36.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  37.     {
  38.         $this->createdAt $createdAt;
  39.         return $this;
  40.     }
  41.     public function getTitle(): ?string
  42.     {
  43.         return $this->title;
  44.     }
  45.     public function setTitle(string $title): self
  46.     {
  47.         $this->title $title;
  48.         return $this;
  49.     }
  50.     public function getBody(): ?string
  51.     {
  52.         return $this->body;
  53.     }
  54.     public function setBody(string $body): self
  55.     {
  56.         $this->body $body;
  57.         return $this;
  58.     }
  59.     public function getGenre(): ?string
  60.     {
  61.         return $this->genre;
  62.     }
  63.     public function setGenre(string $genre): self
  64.     {
  65.         $this->genre $genre;
  66.         return $this;
  67.     }
  68.     public static function createPost(string $titlestring $bodystring $genre): self
  69.     {
  70.         $post = new self();
  71.         $post->setTitle($title);
  72.         $post->setBody($body);
  73.         $post->setGenre($genre);
  74.         $post->setCreatedAt(new \DateTime());
  75.         return $post;
  76.     }
  77.     public function getPhoto(): ?string
  78.     {
  79.         return $this->photo;
  80.     }
  81.     public function setPhoto(?string $photo): self
  82.     {
  83.         $this->photo $photo;
  84.         return $this;
  85.     }
  86.     public function getEpigraph(): ?string
  87.     {
  88.         return $this->epigraph;
  89.     }
  90.     public function setEpigraph(?string $epigraph): self
  91.     {
  92.         $this->epigraph $epigraph;
  93.         return $this;
  94.     }
  95.     public function getPhotoFile(): ?File
  96.     {
  97.         return $this->photoFile;
  98.     }
  99.     public function setPhotoFile(?File $photoFile): self
  100.     {
  101.         $this->photoFile $photoFile;
  102.         return $this;
  103.     }
  104. }