|
|
@ -68,9 +68,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'author')]
|
|
|
|
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'author')]
|
|
|
|
private Collection $comments;
|
|
|
|
private Collection $comments;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var Collection<int, Post>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#[ORM\ManyToMany(targetEntity: Post::class, mappedBy: 'likes')]
|
|
|
|
|
|
|
|
private Collection $liked_post;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->comments = new ArrayCollection();
|
|
|
|
$this->comments = new ArrayCollection();
|
|
|
|
|
|
|
|
$this->liked_post = new ArrayCollection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
public function getId(): ?int
|
|
|
@ -189,4 +196,31 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @return Collection<int, Post>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getLikedPost(): Collection
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->liked_post;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function addLikedPost(Post $likedPost): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$this->liked_post->contains($likedPost)) {
|
|
|
|
|
|
|
|
$this->liked_post->add($likedPost);
|
|
|
|
|
|
|
|
$likedPost->addLike($this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function removeLikedPost(Post $likedPost): static
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ($this->liked_post->removeElement($likedPost)) {
|
|
|
|
|
|
|
|
$likedPost->removeLike($this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|