src/Entity/BlogPost.php line 16
<?phpnamespace App\Entity;use App\Repository\BlogPostRepository;use Doctrine\DBAL\Types\Types;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: BlogPostRepository::class)]#[Vich\Uploadable]class BlogPost{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $titleblog = null;#[Vich\UploadableField(mapping: 'recipe_images', fileNameProperty: 'imageName')]private ?File $imageFile = null;#[ORM\Column(nullable: true)]private ?string $imageName = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $content = null;#[ORM\Column]private ?\DateTimeImmutable $createdAt = null;#[ORM\Column(nullable: true)]private ?\DateTimeImmutable $publishedAt = null;#[ORM\Column(nullable: true)]private ?\DateTimeImmutable $updatedAt = null;#[ORM\Column]private ?bool $isValid = null;#[ORM\Column]private ?bool $deleted = null;#[ORM\Column(length: 50)]private ?string $status = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private $comment;#[ORM\Column(length: 255)]private ?string $slug = null;#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'blogPosts')]private Collection $categories;public function __construct(){$this->categories = new ArrayCollection();$this->createdAt = new \DateTimeImmutable();}public function getComment(): ?string{return $this->comment;}public function setComment(?string $comment): self{$this->comment = $comment;return $this;}public function getSlug(): ?string{return $this->slug;}public function setSlug(string $slug): self{$this->slug = $slug;return $this;}public function getId(): ?int{return $this->id;}public function getTitleBlog(): ?string{return $this->titleblog;}public function setTitleBlog(string $titleblog): self{$this->titleblog = $titleblog;return $this;}public function getContent(): ?string{return $this->content;}public function setContent(?string $content): self{$this->content = $content;$this->updatedAt = new \DateTimeImmutable();return $this;}public function getCreatedAt(): ?\DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(\DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getPublishedAt(): ?\DateTimeImmutable{return $this->publishedAt;}public function setPublishedAt(?\DateTimeImmutable $publishedAt): self{$this->publishedAt = $publishedAt;$this->updatedAt = new \DateTimeImmutable();return $this;}public function getUpdatedAt(): ?\DateTimeImmutable{return $this->updatedAt;}public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self{$this->updatedAt = $updatedAt;return $this;}public function isValid(): ?bool{return $this->isValid;}public function setIsValid(bool $isValid): self{$this->isValid = $isValid;$this->updatedAt = new \DateTimeImmutable();return $this;}public function isDeleted(): ?bool{return $this->deleted;}public function setDeleted(bool $deleted): self{$this->deleted = $deleted;$this->updatedAt = new \DateTimeImmutable();return $this;}public function getStatus(): ?string{return $this->status;}public function setStatus(string $status): self{$this->status = $status;$this->updatedAt = new \DateTimeImmutable();return $this;}/*** @return Collection<int, Category>*/public function getCategories(): Collection{return $this->categories;}public function addCategory(Category $category): self{if (!$this->categories->contains($category)) {$this->categories->add($category);$this->updatedAt = new \DateTimeImmutable();}return $this;}public function removeCategory(Category $category): self{$this->categories->removeElement($category);$this->updatedAt = new \DateTimeImmutable();return $this;}/*** If manually uploading a file (i.e. not using Symfony Form) ensure an instance* of 'UploadedFile' is injected into this setter to trigger the update. If this* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter* must be able to accept an instance of 'File' as the bundle will inject one here* during Doctrine hydration.** @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile*/public function setImageFile(?File $imageFile = null): void{$this->imageFile = $imageFile;if (null !== $imageFile) {// It is required that at least one field changes if you are using doctrine// otherwise the event listeners won't be called and the file is lost$this->updatedAt = new \DateTimeImmutable();}}public function getImageFile(): ?File{return $this->imageFile;}public function setImageName(?string $imageName): void{$this->imageName = $imageName;}public function getImageName(): ?string{return $this->imageName;}}