I need a ManyToMany relation between two classes: User and Document. I have the following:
Class User
/**
* @ORM\Id
* @ORM\Column(type="string")
*/
protected $guid;
/**
* @ORM\ManyToMany(targetEntity="project\DocumentationBundle\Entity\Document", mappedBy="users", cascade={"persist", "remove"})
**/
protected $documents;
Class Document
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
protected $id_doc;
/**
* @ORM\ManyToMany(targetEntity="project\UserBundle\Entity\User", inversedBy="documents")
* @ORM\JoinTable(name="document_user")
*/
protected $users;
What the application should do is when the user publishes a document, he can select which users can see it. That's why I need that relation.
When I try to
php app/console doctrine:schema:update --dump-sql
it fires:
Column name 'id' referenced for relation from project\DocumentationBundle\Entity\Document towards project\UserBundle\Entity\User does not exist.
What am i doing wrong? Please help!!