|
@@ -49,10 +49,18 @@ class Film
|
|
|
|
|
|
/**
|
|
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", inversedBy="films")
|
|
|
+ * @ORM\JoinTable(name="filmsavoir_users")
|
|
|
* @var \Doctrine\Common\Collections\Collection
|
|
|
*/
|
|
|
private $usersWantToView;
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", inversedBy="filmsVus")
|
|
|
+ * @ORM\JoinTable(name="filmsvus_users")
|
|
|
+ * @var \Doctrine\Common\Collections\Collection
|
|
|
+ */
|
|
|
+ private $usersWhoSeen;
|
|
|
+
|
|
|
/**
|
|
|
* @return mixed
|
|
|
*/
|
|
@@ -135,6 +143,7 @@ class Film
|
|
|
{
|
|
|
$this->realisateurs = new \Doctrine\Common\Collections\ArrayCollection();
|
|
|
$this->usersWantToView = new \Doctrine\Common\Collections\ArrayCollection();
|
|
|
+ $this->usersWhoSeen = new \Doctrine\Common\Collections\ArrayCollection();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -222,4 +231,55 @@ class Film
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /////////////////////////////////////////////////////////////////////
|
|
|
+ /**
|
|
|
+ * Add user
|
|
|
+ *
|
|
|
+ * @param \AppBundle\Entity\User $user
|
|
|
+ *
|
|
|
+ * @return film
|
|
|
+ */
|
|
|
+ public function addUserWhoSeen(\AppBundle\Entity\User $user)
|
|
|
+ {
|
|
|
+ $this->usersWhoSeen[] = $user;
|
|
|
+ $user->addFilmVu($this);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Remove user
|
|
|
+ *
|
|
|
+ * @param \AppBundle\Entity\User $user
|
|
|
+ */
|
|
|
+ public function removeUserWhoSeen(\AppBundle\Entity\User $user)
|
|
|
+ {
|
|
|
+ $this->usersWhoSeen->removeElement($user);
|
|
|
+ $user->removeFilmVu($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get usersWantToView
|
|
|
+ *
|
|
|
+ * @return \Doctrine\Common\Collections\Collection
|
|
|
+ */
|
|
|
+ public function getUsersWhoSeen()
|
|
|
+ {
|
|
|
+ return $this->usersWhoSeen;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Inverse ToSee
|
|
|
+ * @param \AppBundle\Entity\User $user
|
|
|
+ */
|
|
|
+ public function inverseUserWhoSeen(\AppBundle\Entity\User $user)
|
|
|
+ {
|
|
|
+ if ($this->usersWhoSeen->contains($user)) {
|
|
|
+ $this->removeUserWhoSeen($user);
|
|
|
+ } else {
|
|
|
+ $this->addUserWhoSeen($user);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|