Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Hotel{
- /**
- * Users is an array collection of User objects
- * @var \Doctrine\Common\Collections\Collection<\DKM\Services\Domain\Model\User>
- * @ORM\ManyToMany(inversedBy="hotels" , cascade={"persist"})
- * @ORM\JoinTable(name="dkm_services_domain_model_hotel_user_join")
- */
- protected $users;
- /**
- * Get the Hotel's users
- *
- * @return \Doctrine\Common\Collections\Collection The Hotel's users
- */
- public function getUsers() {
- return $this->users;
- }
- /**
- * Sets this Hotel's users
- *
- * @param \Doctrine\Common\Collections\Collection $users The Hotel's users
- * @return void
- */
- public function setUsers(\Doctrine\Common\Collections\Collection $users) {
- $this->users = $users;
- }
- }
- class User{
- /**
- * @var \Doctrine\Common\Collections\Collection<\DKM\Services\Domain\Model\Hotel>
- * @ORM\ManyToMany(mappedBy="users" , cascade={"persist"})
- */
- protected $hotels;
- /**
- * Get the Users's hotels
- *
- * @return \Doctrine\Common\Collections\Collection The Users's hotels
- */
- public function getHotels() {
- return $this->hotels;
- }
- /**
- * Sets this User's hotel
- *
- * @param \Doctrine\Common\Collections\Collection $users The User's hotels
- * @return void
- */
- public function setHotels(\Doctrine\Common\Collections\Collection $hotels) {
- $this->hotels = $hotels;
- }
- }
- I have an association table (jointable) with users and hotels (this is automatically generated by a doctrine:update command) and with two columns:
- user|hotel
- a b
- c b
- So, two different users should belong to the same hotel. But if I dump the hotel object with the users associated, the users seem to be assigned to two different hotels.
- And If I render the hotels thru a JsonView, I cannot display any user (actually, there's no "users" data in it) in the Json string.
- Thank you in advance for any hint!
- Davide
Advertisement
Add Comment
Please, Sign In to add comment