You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
3.7 KiB

<?php
namespace App\Entity;
use App\Repository\PostRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PostRepository::class)]
class Post
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(length: 512, nullable: true)]
private ?string $text = null;
#[ORM\Column]
private ?bool $isDream = null;
#[ORM\Column]
private ?int $upVote = null;
#[ORM\Column]
private ?int $downVote = null;
#[ORM\ManyToOne(inversedBy: 'posts')]
#[ORM\JoinColumn(nullable: false)]
private ?Profil $profil = null;
/**
* @var Collection<int, Commentary>
*/
#[ORM\OneToMany(targetEntity: Commentary::class, mappedBy: 'post')]
private Collection $commentaries;
/**
* @var Collection<int, Tags>
*/
#[ORM\ManyToMany(targetEntity: Tags::class, inversedBy: 'posts')]
private Collection $tags;
public function __construct()
{
$this->commentaries = new ArrayCollection();
$this->tags = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): static
{
$this->title = $title;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(?string $text): static
{
$this->text = $text;
return $this;
}
public function isDream(): ?bool
{
return $this->isDream;
}
public function setDream(bool $isDream): static
{
$this->isDream = $isDream;
return $this;
}
public function getUpVote(): ?int
{
return $this->upVote;
}
public function setUpVote(int $upVote): static
{
$this->upVote = $upVote;
return $this;
}
public function getDownVote(): ?int
{
return $this->downVote;
}
public function setDownVote(int $downVote): static
{
$this->downVote = $downVote;
return $this;
}
public function getProfil(): ?Profil
{
return $this->profil;
}
public function setProfil(?Profil $profil): static
{
$this->profil = $profil;
return $this;
}
/**
* @return Collection<int, Commentary>
*/
public function getCommentaries(): Collection
{
return $this->commentaries;
}
public function addCommentary(Commentary $commentary): static
{
if (!$this->commentaries->contains($commentary)) {
$this->commentaries->add($commentary);
$commentary->setPost($this);
}
return $this;
}
public function removeCommentary(Commentary $commentary): static
{
if ($this->commentaries->removeElement($commentary)) {
// set the owning side to null (unless already changed)
if ($commentary->getPost() === $this) {
$commentary->setPost(null);
}
}
return $this;
}
/**
* @return Collection<int, Tags>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tags $tag): static
{
if (!$this->tags->contains($tag)) {
$this->tags->add($tag);
}
return $this;
}
public function removeTag(Tags $tag): static
{
$this->tags->removeElement($tag);
return $this;
}
}