Reputation: 445
I want to to add exclusive/inclusive products to promotion entity. There is a clash of names when it tries to generate mapping table.
like:
promotion_product for both tables
manyToMany:
productsIncluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
productsExcluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
I am guessing that this can be achieved but having something like this:
manyToMany:
productsIncluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
joinTable:
name: promotion_included_product
joinColumns:
promotion_id:
referencedColumnName: id
inverseJoinColumns:
product_id:
referencedColumnName: id
productsExcluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
joinTable:
name: promotion_excluded_product
joinColumns:
promotion_id:
referencedColumnName: id
inverseJoinColumns:
product_id:
referencedColumnName: id
Is this a way?, or is there an easier/cleaner way that symfony auto handles this?
Let me know thanks.
Upvotes: 0
Views: 435
Reputation: 9246
That's the way, although joinColumns and inverseJoinColumns defaults should be the same as you typed so you could shorten it to:
manyToMany:
productsIncluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
joinTable:
name: promotion_included_product
productsExcluded:
targetEntity: Acme\Bundle\DemoBundle\Entity\Product
joinTable:
name: promotion_excluded_product
Upvotes: 1