<?phpnamespace App\Entity;use App\Repository\PostsRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: PostsRepository::class)]class Posts{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $titulo = null; #[ORM\Column(length: 1000, nullable: true)] private ?string $likes = null; #[ORM\Column(length: 255, nullable: true)] private ?string $foto = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $fecha_publicacion = null; #[ORM\Column(length: 80000)] private ?string $contenido = null; #[ORM\ManyToOne(inversedBy: 'posts')] #[ORM\JoinColumn(nullable: false)] private ?User $user = null; #[ORM\OneToMany(mappedBy: 'posts', targetEntity: Comentarios::class, orphanRemoval: true)] private Collection $comentarios; public function __construct() { $this->likes=''; $this->fecha_publicacion=new \DateTime(); $this->comentarios = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitulo(): ?string { return $this->titulo; } public function setTitulo(string $titulo): static { $this->titulo = $titulo; return $this; } public function getLikes(): ?string { return $this->likes; } public function setLikes(?string $likes): static { $this->likes = $likes; return $this; } public function getFoto(): ?string { return $this->foto; } public function setFoto(string $foto): static { $this->foto = $foto; return $this; } public function getFechaPublicacion(): ?\DateTimeInterface { return $this->fecha_publicacion; } public function setFechaPublicacion(\DateTimeInterface $fecha_publicacion): static { $this->fecha_publicacion = $fecha_publicacion; return $this; } public function getContenido(): ?string { return $this->contenido; } public function setContenido(string $contenido): static { $this->contenido = $contenido; return $this; } public function getPosts(): ?self { return $this->posts; } public function setPosts(?self $posts): static { $this->posts = $posts; return $this; } public function addPost(self $post): static { if (!$this->posts->contains($post)) { $this->posts->add($post); $post->setPosts($this); } return $this; } public function removePost(self $post): static { if ($this->posts->removeElement($post)) { // set the owning side to null (unless already changed) if ($post->getPosts() === $this) { $post->setPosts(null); } } return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): static { $this->user = $user; return $this; } /** * @return Collection<int, Comentarios> */ public function getComentarios(): Collection { return $this->comentarios; } public function addComentario(Comentarios $comentario): static { if (!$this->comentarios->contains($comentario)) { $this->comentarios->add($comentario); $comentario->setPosts($this); } return $this; } public function removeComentario(Comentarios $comentario): static { if ($this->comentarios->removeElement($comentario)) { // set the owning side to null (unless already changed) if ($comentario->getPosts() === $this) { $comentario->setPosts(null); } } return $this; }}