We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0db7504 commit 8017175Copy full SHA for 8017175
src/AppBundle/Entity/Post.php
@@ -227,16 +227,20 @@ public function getComments()
227
*/
228
public function addComment(Comment $comment)
229
{
230
- $this->comments->add($comment);
231
- $comment->setPost($this);
+ if (!$this->comments->contains($comment)) {
+ $this->comments->add($comment);
232
+ $comment->setPost($this);
233
+ }
234
}
235
236
/**
237
* @param Comment $comment
238
239
public function removeComment(Comment $comment)
240
- $this->comments->removeElement($comment);
241
+ if ($this->comments->removeElement($comment)) {
242
+ $comment->setPost(null);
243
244
245
246
0 commit comments