src/Entity/Posts.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PostsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPostsRepository::class)]
  9. class Posts
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $titulo null;
  17.     #[ORM\Column(length1000nullabletrue)]
  18.     private ?string $likes null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $foto null;
  21.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  22.     private ?\DateTimeInterface $fecha_publicacion null;
  23.     #[ORM\Column(length80000)]
  24.     private ?string $contenido null;
  25.     #[ORM\ManyToOne(inversedBy'posts')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private ?User $user null;
  28.     #[ORM\OneToMany(mappedBy'posts'targetEntityComentarios::class, orphanRemovaltrue)]
  29.     private Collection $comentarios;
  30.     public function __construct()
  31.     {
  32.     $this->likes='';
  33.     $this->fecha_publicacion=new \DateTime();
  34.         $this->comentarios = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getTitulo(): ?string
  41.     {
  42.         return $this->titulo;
  43.     }
  44.     public function setTitulo(string $titulo): static
  45.     {
  46.         $this->titulo $titulo;
  47.         return $this;
  48.     }
  49.     public function getLikes(): ?string
  50.     {
  51.         return $this->likes;
  52.     }
  53.     public function setLikes(?string $likes): static
  54.     {
  55.         $this->likes $likes;
  56.         return $this;
  57.     }
  58.     public function getFoto(): ?string
  59.     {
  60.         return $this->foto;
  61.     }
  62.     public function setFoto(string $foto): static
  63.     {
  64.         $this->foto $foto;
  65.         return $this;
  66.     }
  67.     public function getFechaPublicacion(): ?\DateTimeInterface
  68.     {
  69.         return $this->fecha_publicacion;
  70.     }
  71.     public function setFechaPublicacion(\DateTimeInterface $fecha_publicacion): static
  72.     {
  73.         $this->fecha_publicacion $fecha_publicacion;
  74.         return $this;
  75.     }
  76.     public function getContenido(): ?string
  77.     {
  78.         return $this->contenido;
  79.     }
  80.     public function setContenido(string $contenido): static
  81.     {
  82.         $this->contenido $contenido;
  83.         return $this;
  84.     }
  85.     public function getPosts(): ?self
  86.     {
  87.         return $this->posts;
  88.     }
  89.     public function setPosts(?self $posts): static
  90.     {
  91.         $this->posts $posts;
  92.         return $this;
  93.     }
  94.     public function addPost(self $post): static
  95.     {
  96.         if (!$this->posts->contains($post)) {
  97.             $this->posts->add($post);
  98.             $post->setPosts($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removePost(self $post): static
  103.     {
  104.         if ($this->posts->removeElement($post)) {
  105.             // set the owning side to null (unless already changed)
  106.             if ($post->getPosts() === $this) {
  107.                 $post->setPosts(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     public function getUser(): ?User
  113.     {
  114.         return $this->user;
  115.     }
  116.     public function setUser(?User $user): static
  117.     {
  118.         $this->user $user;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection<int, Comentarios>
  123.      */
  124.     public function getComentarios(): Collection
  125.     {
  126.         return $this->comentarios;
  127.     }
  128.     public function addComentario(Comentarios $comentario): static
  129.     {
  130.         if (!$this->comentarios->contains($comentario)) {
  131.             $this->comentarios->add($comentario);
  132.             $comentario->setPosts($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeComentario(Comentarios $comentario): static
  137.     {
  138.         if ($this->comentarios->removeElement($comentario)) {
  139.             // set the owning side to null (unless already changed)
  140.             if ($comentario->getPosts() === $this) {
  141.                 $comentario->setPosts(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146. }