Doctrine ORM ManyToMany bidirectional error

1

I have a query about my entity that gives me an error, I'll show the entity and the error:

    class Post implements ResourceInterface, TranslatableInterface
{
    /**
     * @var int
     */
    private $id;

    /**
     * @var bool
     */
    private $important;
    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Tag", inversedBy="posts")
     * @ORM\JoinTable(name="posts_tags",
     *   joinColumns={
     *     @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
     *   }
     * )
     */
    private $tags;
}

The other entity is tag

class Tag implements ResourceInterface, TranslatableInterface
{
    use TranslatableTrait {
        __construct as private initializeTranslationsCollection;
    }

    /**
     * @var int
     */
    private $id;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Post", mappedBy="tags")
     */
    private $posts;
}

But this when verifying it gives the following error:

Mapping

 [FAIL] The entity-class AppBundle\Entity\Tag mapping is invalid:
 * The field AppBundle\Entity\Tag#posts is on the inverse side of a bi- 
 directional relationship, but the specified mappedBy association on the 
 target-entity AppBundle\Entity\Post#tags does not contain the required 
 'inversedBy="posts"' attribute.

I hope you can help me.

    
asked by Y2ksystem 11.10.2018 в 20:02
source

0 answers