A
A
Alexander2016-12-02 10:53:47
symfony
Alexander, 2016-12-02 10:53:47

How to properly organize the structure of entities?

How to properly organize the structure?
At the moment there are two
Book entities - booking
Extra - Additional services
when booking a person can add a few additional points to the base price
, because of this the total amount will increase
, you need to get the price of additional services and their names and attach this economy to the Book
I'm a little confused already. As I see the solution:
An additional BookExtra entity is created
in Book via OneToOne and bound to BookExtra
* @ORM\OneToOne(targetEntity="AppBundle\Entity\BookExtra")
* @ORM\JoinColumn(name="bookextra_id", referencedColumnName="id")
everything is clear here
And BookExtra needs to be tied to Extra, it seems to me through the OneToMany relationship.
One BookExtra can have several Extras.
How can I describe the connection in this case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mark Kalerin, 2016-12-04
@Vosined_12

And why it is impossible to do without the third entity? Wouldn't it be logical to keep the price of the add. services just in one more field of entity Book?

P
Polim, 2016-12-09
@Polim

ManyToMany relationship, symfony will automatically create a table with relationships

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question