I have two tables, Event and Product, one Event has multiple products and one product can be in multiple Events. Here I think it's a OneToMany Unidirectional relationship. In the form of Event creation I want to have the list of available products in the database and add some products to the event (collection of products).
What's the best way to do that?
Can anyone help me to choose the best way and how to implement it?
1)Implement the onetomany:
In this case you can get the event products list : $event->getProducts
But when you need to access to the event from the product entity via $product->getEvent() !!!!!! this is impossible because the relation is unidirectional
2) Go in the way to implement ManyToMany and create a third table EventProducts :
The solution is this one and create the third entity EventProduct
Hope this can helps